perm filename MANUAL.TEX[MF,DEK]4 blob
sn#484239 filedate 1979-10-26 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00020 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00003 00002 \input manhdr[mf,dek] % This is the METAFONT user manual source text
C00013 00003 \titlepage
C00025 00004 \manmark{Table of Contents}{\chead}\penalty-100\vfill
C00028 00005 \chapterbegin 1. {The basics}
C00043 00006 \chapterbegin 2. {Curves}
C00080 00007 \chapterbegin 3. {Pens and erasers}
C00102 00008 \chapterbegin 4. {Running \MF}
C00137 00009 \specialchapterbegin 5. {Variables, expressions, and equations}
C00168 00010 \chapterbegin 6. {Filling in between curves}
C00187 00011 \chapterbegin 7. {Discreteness and discretion}
C00204 00012 \chapterbegin 8. {Subroutines}
C00229 00013 \chapterbegin 9. {Summary of the language}
C00265 00014 \chapterbegin 10. {Recovery from errors}
C00313 00015 \specialappbegin A. {Answers to all the exercises}
C00322 00016 \specialappbegin E. {Example of a font definition}
C00371 00017 \specialappbegin F. {Font information for \TEX}
C00400 00018 \specialappbegin I. {Index}
C00415 00019 \postindexappbegin Z. {Dragon curve for Fig.\ 4--2}
C00417 00020 \specialappbegin {\char5}. {Pseudo-random design}
C00427 ENDMK
C⊗;
\input manhdr[mf,dek] % This is the METAFONT user manual source text
\titlepage
\tenpoint
\null\vskip-46pt
\hbox to size{\:<Stanford Artificial Intelligence Laboratory\hfill September
1979}
\hbox to size{\:<Memo AIM-332\hfill(first printing)}
\vskip .25in
\hbox{\:<Computer Science Department}
\hbox{\:<Report No. STAN-CS-79-762}
\vfill
\ctrline{\:<METAFONT, a system for alphabet design}
\vskip .25in
\ctrline{$\copyright$ 1979 by the American Mathematical Society}
\vskip 3pt
\ctrline{All rights reserved}
\vfill
\ctrline{\baselineskip9pt
\hbox par 360pt{\eightpoint Like most computer manuals nowadays, this is a
preliminary version. The real manual will be properly typeset, and its figures
will be much better, but it seems wise to circulate this draft now so that more
people can enjoy playing with the system. The author wishes to thank the many
individuals who made detailed comments on pre-preliminary drafts. This work
was supported in part by National Science Foundation grant MCS 72-03752, by
Office of Naval Research grant N0014-76-C-0330, and by the IBM Corporation.
Reproduction in whole or in part is permitted for any purpose of the United
States Government.}}
\gdef\chead{Preface}
\manmark{\chead}{\chead}
\setcount0 0
\eject
\titlepage
\null\vskip-10pt
\vskip 1in plus 1in
\ctrline{\:;()*+,-.*}
\vskip 13pt
\ctrline{\:q A SYSTEM FOR ALPHABET DESIGN}
\vskip .5in plus .5in
\tenpoint
\noindent\hangindent 25pt for 2
\hbox to 0pt{\hskip-25pt\:@\char'176\hfill}\hskip-6pt
{\:c ENERATION} {\:c OF} {\:c TYPEFACES} by mathematical means was first
tried in the fifteenth century; it became popular in the sixteenth and
seventeenth centuries; and it was abandoned (for good reason) during the
eighteenth century. Perhaps the twentieth century will turn out to be the
right time for this idea to make a comeback, now that mathematics has advanced
and computers are able to do the calculations.
Modern printing equipment based on raster lines---in which metal ``type''
has been replaced by purely combinatorial patterns of zeros and ones that specify
the desired position of ink in a discrete way---makes mathematics and computer
science increasingly relevant to printing. We now have the ability to give
a completely precise definition of letter shapes that will produce essentially
equivalent results on all raster-based machines. Furthermore it is possible
to define infinitely many styles of type at once; computers can ``draw'' new
fonts of characters in seconds, so that a designer is able to perform valuable
experiments that were previously unthinkable.
\MF\ is a system for the design of alphabets suited to raster-based devices
that print or display text. The characters you are reading were all designed
with \MF, in a completely precise way; and they were developed rather hastily
by the author of the system, who is a rank amateur at such things. It seems
clear that further work with \MF\ has the potential of producing typefaces of
real beauty, so this manual has been written for people who would like to
help advance the art of mathematical type design.
A \MF\ user writes a ``program'' for each letter or other symbol that is
desired. Ideally the programs will be expressed in terms of variable parameters,
so that a wide variety of typefaces can be obtained, simply by changing the
parameters; but \MF\ can also be used to define a single solitary font, or
even a single character, if anybody really wants to.
It is harder to write a
\MF\ program than to draw a character with pen and ink, but once the
program has been written you can easily ``parameterize'' it so that the
letter shapes will adapt themselves to different specifications. And it is
easier to write a \MF\ program than to draw a character ten times. Therefore
\MF\ is usually used to provide an entire family of related fonts. By varying
the programs and the parameters, you will be able to determine the most
pleasing settings.
\MF\ programs are expressed in a declarative algebraic language that is rather
different from ordinary computer languages, since it has been developed
especially for the problems of type design. In this language you explain where
the major components of a desired shape are located, and you specify how the shape
is to be drawn using ``pens'' and ``erasers.'' One of the advantages of \MF\
is that it provides a discipline according to which the principles of a
particular alphabet design are stated explicitly---the underlying intelligence
does not remain hidden in the mind of the designer, it is spelled out in the
programs. Thus it is comparatively easy to obtain consistency where
consistency is desirable, and to extend a font to new symbols that are
compatible with the existing ones.
This manual is not a textbook about mathematics or about computers. But if
you know the rudiments of those subjects (contemporary high school
mathematics, together with the knowledge of how to use the text editor on
your computer), you should be able to use \MF\ with little difficulty
after reading what follows. Some parts of the manual are more obscure than
others, however, since the author has tried to satisfy experienced \MF\hskip-.7pt
ers as well as beginners and casual users with a single manual. Therefore a
special symbol has been used to warn about esoterica: When you see the sign
$$\vbox{\hbox{\:@\char'177}\vskip 11pt}$$
at the beginning of a paragraph, watch out for a ``dangerous bend'' in the train
of thought---don't read such a paragraph unless you need to. You will be able
to use \MF\ reasonably well, even to design characters like the dangerous-bend
symbol itself, without reading the fine print in such advanced sections.
Computer system manuals usually make dull reading, but take heart:
This one contains {\:m JOKES} every once in a while, so you might actually
enjoy reading it.\xskip (Most of the jokes can only be appreciated
properly if you understand a technical point that is being made, however---so
read {\sl carefully}.)
In order to help you internalize what you're reading, occasional
{\:m EXERCISES} are sprinkled through this manual. It is generally intended
that every reader should try every exercise, except for the exercises that appear
in the ``dangerous bend'' areas. If you can't solve the problem, you
can always look at the answer pages at the end of the manual.
But please, try first to solve it by yourself; then you'll learn more
and you'll learn faster. Furthermore, if you think you do know the answer to
an exercise, you should turn to the official answer (in Appendix A)
and check it out just to make sure.
\manmark{Table of Contents}{\chead}\penalty-100\vfill
\ctrline{\:<CONTENTS}\vskip 6pt
\manmark{Table of Contents}{Table of Contents}\gdef\chead{Table of Contents}
\tenpoint
{\def\\#1. #2. #3.{\hbox to size{\hbox to .5em{\hskip 0pt plus 1000pt minus 1000pt
\bf#1}\hbox{\bf. }#2
\leaders\hrule\hfill\hbox to 20pt{\hfill#3}}}
\\1. The basics. 4.
\\2. Curves. 8.
\\3. Pens and erasers. 22.
\\4. Running \MF. 29.
\\5. Variables, expressions, and equations. 39.
\\6. Filling in between curves. 46.
\\7. Discreteness and discretion. 51.
\\8. Subroutines. 55.
\\9. Summary of the language. 61.
\\10. Recovery from errors. 69.
\\A. Answers to all the exercises. 81.
\\E. Example of a font definition. 82.
\\F. Font information for \TEX. 95.
\\I\hskip 1pt. Index. 102.
} % end table of contents
\chapterbegin 1. {The basics}
To define a shape using \MF, you don't draw it; you explain {\sl how} to
draw it. Explanation is generally harder than doing---for example, it's
much easier to walk than to teach a robot how to walk---but the \MF\
language is intended to make the job of explanation relatively painless.
Once you have explained how to draw some shape in a sufficiently general manner, the
same explanation will work for related shapes, in different circumstances;
so the time spent in formulating a precise explanation turns out to be
worth it. The ``{\:; META}-'' of ``\hbox{\MF}'' is meant to indicate the fact that
a general explanation of how to draw a font of characters will transcend any
particular set of drawings for those characters.
To explain how to draw a shape, we need a precise way to specify various
key points of that shape. \MF\ uses standard Cartesian coordinates for
this purpose [following Ren\'e Descartes, whose revolutionary work
{\sl La g\'eom\'etrie} in 1637 marked the beginning of the application of
algebraic methods to geometric problems]: The location of a point is
defined by specifying its $x$ coordinate, which is the number of units to
the right of some reference point, and its $y$ coordinate, which is the
number of units upwards from the reference point.
For example, the six points shown in \fig 1-1 have the following $x$ and $y$
coordinates:
$$\baselineskip 15pt
\vbox{\halign{$(#)=(0,\null$⊗$\hfill#);$\qquad
⊗$(#)=(100,\null$⊗$\hfill#);$\qquad
⊗$(#)=(200,\null$⊗$\hfill#$\cr
x↓1,y↓1⊗100⊗x↓2,y↓2⊗100⊗x↓3,y↓3⊗100);\cr
x↓4,y↓4⊗0⊗x↓5,y↓5⊗0⊗x↓6,y↓6⊗0).\cr}}$$
These six points will be used in several examples that follow.
All points in \MF\ programs are given an identifying number, which should be
a positive integer (or zero). The $x$ and $y$ coordinates of each point are
specified by so-called $x$-variables and $y$-variables; for example, ``$x↓2$''
and ``$y↓2$'' are the coordinates of point 2.
In a typical application of \MF, you prepare a rough sketch of the shape you
plan to define, on a piece of graph paper, and you label the key points on
that sketch with any convenient numbers. Then you write a \MF\ program that
explains (i) how to figure out the coordinates of those key points, and (ii) how
to draw the desired lines and curves between those points.
\MF\ programs for individual characters
consist of a bunch of ``state\-ments'' separated by semicolons and
ending with a period. The most common form of statement is an {\sl equation}
that expresses one or more algebraic relationships between variables. For
example, consider the equations
$$\baselineskip 15pt
\cpile{x↓1=x↓4=y↓4=y↓5=y↓6=0;\cr
x↓2=x↓5=y↓1=y↓2=y↓3=100;\cr
x↓3=x↓6=200;\cr}$$
these suffice to define the six points of \fig 1-1.
\topinsert{\rjustline{\caption 1-1(80pt){Six points that will be used in
several examples of this chapter and the next.}}}
Points are rarely specified in terms of fixed numbers like 100, however, since
we will see later that this means a distance of 100 units on the square grid or
``raster'' that \MF\ works with. An alphabet
defined in such absolute terms would come out looking very tiny on high-resolution
machines but very large on machines with only a few raster units per inch.
It is clearly better to write something like this:
$$\baselineskip 15pt
\cpile{x↓1=x↓4=0;\quad x↓2=x↓5=d;\quad x↓3=x↓6=2d;\cr
y↓1=y↓2=y↓3=h;\quad y↓4=y↓5=y↓6=0;\cr}$$
the auxiliary variables $h$ and $d$, which we can assume have been defined at the
very beginning of our \MF\ specifications, can readily be adjusted to give any
desired scaling, without changing the rest of the program.
There are lots of other ways to specify the coordinates of those six points.
For example, the equation ``$x↓3=x↓6=2d$'' could have been replaced by
``$x↓3=x↓6=x↓2+d$'', or even by an implicit formula such as
$$x↓3-x↓2=x↓6-x↓5=x↓2-x↓1.$$
The latter formula states that the horizontal distance from point 3 to point 2
is the same as from point 6 to point 5 and from point 2 to point 1. \MF\ will
solve such implicit equations as long as they remain linear; further details
about equations are discussed in Chapter 5.
Of course there's no point in being able to define points unless there is
something you can do with them. In particular, we want to be able to draw a
straight line from one point to another. \MF\ uses ``pens'' to draw lines,
and in our first examples we shall be using a circular pen that is nine raster
units in diameter. We can write, for example,
$$\&{cpen};\quad 9\;\draw 1\to6;$$
these statements
instruct \MF\ to take a circular pen (``\&{cpen}'') of width 9 and to draw
a straight line from point 1 to point 6, producing \fig 1-2. We get to
\fig 1-3 after the subsequent statements
$$\draw 2\to5;\quad\draw 3\to4;$$
note that it is not necessary to respecify the ``\&{cpen}'' or the ``9''
when the pen does not change.
\topinsert{\rjustline{\caption 1-2(80pt){A straight line drawn by \MF\ with
a circular pen.}}}
\botinsert{\caption 1-3(85pt){After two more lines we obtain a design something
like the Union Jack.}}
\def\¬{\hskip .2em}
If \fig 1-3 were to be scaled in such a way that 100 raster units came out exactly
equal to the
height of the letters in this paragraph, the character we have drawn would
be \hbox{``\¬{\:;1}\¬''}. Just for fun, let's try to typeset ten of them in a row:
\hbox{``\¬{\:;1111111111}\¬''}. How easy it is to do this!\footnote*{Now that authors
have for the first time the power to invent new symbols with great ease, and
to have those characters printed in their manuscripts on a wide variety of
typesetting devices, we have to face the question of how much experimentation
is desirable. Will font freaks abuse this toy by overdoing it? Is it wise to
introduce new symbols by the thousands? Such questions are beyond the scope
of this manual; but it is easy to imagine an epidemic of fontomania occurring,
once people realize how much fun it is to design their own characters, and it may
be necessary to perform fontal lobotomies.}
The most important thing to notice about \fig 1-3 is that the {\sl center} of
the pen goes from point to point when drawing a line. For example, points 1 and
6 do not appear at the edge of the line we have drawn from 1 to 6; they appear
in the middle of the starting and stopping positions. In other words, we did
not describe the boundary of the character, we described the pen motion. This
makes it easy to do things like switch to a ``boldface'' {\:;1}\¬, namely to a
{\:;2}\¬, merely by using a \&{cpen} of width 15 instead of width 9.
Pen widths are usually specified by so-called $w$-variables, which are somewhat
analogous to $x$-variables and $y$-variables. For example, the normal procedure
would be to define $w↓1=9$ at the beginning of our program, then to write
$$\&{cpen};\quad w↓1\;\draw 1\to6;\quad\draw 2\to5;\quad\draw 3\to4;$$
by changing $w↓1$ to 15 we would then get the boldface symbol without changing
the rest of the program.
Since \MF\ draws things by describing the motion of a pen's center, it is
desirable to have a way to specify the points so that the edge of the pen will
be at a known place. For example, our character ``\¬{\:;1}\¬'' actually extends
slightly below the baseline ($y=0$) of normal lines of type, because the
pen of width 9 extends 4 units below the baseline when the center of the
pen is on the baseline. And the boldface {\:;2} goes down even further. The remedy
for this is to define $y↓4$ by using a special ``\&{bot}'' notation, e.g.,
$$\&{bot}↓1y↓4=0,$$
which means that the bottom of the pen will be at 0 when the pen of width $w↓1$
is at point 4.\xskip(The ``1'' in ``$\&{bot}↓1$'' refers to the ``1'' in
``$w↓1$''; thus, the \&{bot} notation is meaningful only when the corresponding
$w$-variable has a definite value.)\xskip Similarly,
$$\&{top}\null↓1y↓1=100$$
would say that the top of the pen will be at 100 when the pen of width $w↓1$ is
at point 1.
Using these ideas, we can revise our example program to obtain the following
statements (assuming that $h$, $d$, and $w↓1$ have already been defined and
that the character's height and width have been set to $h$ and $2d$, respectively):
$$\baselineskip 15pt\lpile{
x↓1=x↓4=0;\quad x↓2=x↓5=d;\quad x↓3=x↓6=2d;\cr
y↓1=y↓2=y↓3;\quad y↓4=y↓5=y↓6;\cr
\&{top}\null↓1y↓1=h;\quad \&{bot}↓1y↓4=0;\cr
\&{cpen};\quad w↓1\;\draw1\to6;\quad\draw2\to5;\quad\draw3\to4.\cr}$$
This program gives the characters {\:;3} and {\:;4} when $w↓1=9$ and $w↓1=15$,
respectively; close inspection reveals
that these characters just touch the baseline, and they
are exactly as tall as an ``h''.
\yskip\noindent
\exno 1.1: Ten of the above characters will result in $$\hbox{\:;3333333333};$$note
that adjacent characters join together, since the character width is $2d$, so
that points 3 and 6 of one character coincide with points 1 and 4 of the next.
Suppose that we actually wanted the characters to be completely confined to
a rectangular box of width $2d$, so that adjacent characters would come just
shy of touching
(\¬{\:;5555555555}\¬). Explain how to modify the example program
above so that this would happen, assuming that \MF\ has operations ``\&{lft}''
and ``\&{rt}'' analogous to ``\&{top}'' and ``\&{bot}''.
\chapterbegin 2. {Curves}
The sixteenth-century methods of mathematical type design failed because
ruler and compass constructions were inadequate to express the nuances
of good calligraphy. \MF\ attempts to get around this problem by using
more powerful mathematical techniques: it provides automatic facilities
for drawing ``pleasing'' curves, and this chapter explains how to use them.
The \&{draw} command introduced in Chapter 1 will produce curved lines, instead
of straight lines, when it is given a list of more than two points. For
example, let's go back to the six points of \fig 1-1 and consider the
effect of
$$\&{cpen};\quad 9\;\draw5\to4\to1\to3\to6\to5;$$
this produces a closed curve from point 5 to point 4 to point 1 to point 3 to
point 6 to point 5, as shown in \fig 2-1.
$$\rjustline{\caption 2-1(140pt){A curve that passes through five
of the six example points.}}$$
The bean-shaped path of \fig 2-1 isn't bad looking, but it might not be the
curve we had in mind. Indeed, if the \&{draw} command had been ``$\draw
4\to1\to3$'' instead of the more complicated example above, we would have gotten
the curve of \fig 2-2,\botinsert{\caption 2-2(95pt){If you don't understand how
\MF\ draws curves, you might get ungraceful shapes.}}
which is almost surely not what anybody wants.
Something went wrong here, so it is important to get a clear idea of how
\MF\ actually decides what curves to draw.
\MF's rules are (fortunately) quite simple. The curve between two points
$z↓1$ and $z↓2$ depends only on four things:
$$\vbox{\halign{#\hfill\cr
the location of $z↓1=(x↓1,y↓1)$;\cr
the location of $z↓2=(x↓2,y↓2)$;\cr
the angle of the curve at $z↓1$;\cr
the angle of the curve at $z↓2$;\cr}}$$
Once these four things are given, \MF\ knows what curve it will draw.
But how are the angles at $z↓1$ and $z↓2$ chosen? Again there is a simple
rule: If the curve goes from $z↓0$ to $z↓1$ to $z↓2$, the direction
it takes as it passes through $z↓1$ is the same as the direction of the arc
of a {\sl circle} from $z↓0$ to $z↓1$ to $z↓2$. Thus, for example, since
both Figs.\ \hbox{2--1} and \hbox{2--2} have curves that run from 4 to 1 to 3, both
curves have the same direction as they pass point 1, namely the direction
of the circle determined by points 4, 1, and 3.\xskip(It is well known and
not difficult to prove that there is a unique circle passing through any
three distinct points $z↓0$, $z↓1$, and $z↓2$, unless these points lie on a
straight line. We will not worry just now about the exceptional cases
when the points are collinear or not distinct.)
An important {\sl locality property} follows from the two rules just
stated: Each segment of a \MF\ curve depends only on the locations of the
two endpoints of that segment and the locations of its two neighboring points.
For if the segment runs from $z↓1$ to $z↓2$, and if the
previous point is $z↓0$ and the next point is $z↓3$, the angle at $z↓1$ is
determined by $z↓0$, $z↓1$, and $z↓2$, while the angle at $z↓2$ is determined
by $z↓1$, $z↓2$, and $z↓3$. Other parts of the curve will have no effect;
thus you can fix up any segments you don't like without harming the
segments you do like.
So far we have discussed what the curve depends on, but not what the curve really
is. \MF's curves satisfy an {\sl invariance property} in addition to their
locality property, in the following sense: Shifting a curve to the left or
right, or up or down, does not change its shape, and rotation doesn't
change the shape
either. Furthermore if all coordinates are multiplied by some factor, the
curve simply grows or shrinks by that factor.\xskip
(In mathematical terms, using complex variable notation, the curve through
points $αz↓1+β$, $\ldotss$, $αz↓n+β$ is equal to $α$ times the curve through
points $z↓1$, $\ldotss$, $z↓n$, plus $β$.)\xskip Therefore we need only
describe the curve from $z↓1$ to $z↓2$ when $z↓1=(x↓1,y↓1)=(0,0)$ and
$z↓2=(x↓2,y↓2)=(150,0)$, say, and when the curve leaves $z↓1$ at a given
angle $\theta$ and enters $z↓2$ at a given angle $\phi$ with respect to
the horizontal. These special curves will produce all other \MF\ curves if
we shift them, rotate them, and expand or contract them.
\fig 2-3 shows typical curves that leave $z↓1$ at an angle of $60\deg$,
coming in to point $z↓2$ at angles of $120\deg$, $90\deg$, $60\deg$,
$30\deg$, and $0\deg$. When both angles are $60\deg$, the curve is essentially
the arc of a circle; when one angle is $60\deg$ and the other is $30\deg$,
the curve is essentially a quarter-ellipse.\xskip(\MF's circles and ellipses
aren't absolutely perfect, since they are approximated by cubic curves,
but the error is much too small to be perceived.)\xskip At other angles
the curves in \fig 2-3 are less familiar mathematical objects, but at
least they have a reasonable shape.
\topinsert{\rjustline{\caption 2-3(80pt){Examples of \MF's standard curves,
leaving point 1 at an angle of $60\deg$ from the horizontal and entering
point 2 at various multiples of $30\deg$.}}}
\fig 2-4 shows several more curves that leave $z↓1$ at $60\deg$; but this
time the curves have been forced to come into $z↓2$ from {\sl below} the
horizontal, at angles of $-30\deg$, $-60\deg$, $-90\deg$, and $-120\deg$.
Most of these curves (with the possible exception of the $-60\deg$ one) are
rather arbitrary, so you are taking a chance if you expect \MF\ to change
directions so drastically.
\botinsert{\rjustline{\caption 2-4(97pt){Examples of \MF's standard curves,
when the outgoing and incoming angles have opposite signs.}}}
Now let's return to the problem of \fig 2-2; why did \MF\ choose such an
ugly curve when commanded to ``$\draw4\to1\to3$''? The answer is that no
angle was specified for the curve at its beginning point 4 or at its
ending point 3; so \MF\ used the directions from 4 to 1 and from 1 to 3, in
order to be consistent with the two-point (straight line) case. In other
words, the failure occurred because we didn't give \MF\ a clue about how the
curve should be started and stopped. {\sl When drawing curved lines, it is
almost always desirable to specify the beginning and ending angles somehow},
otherwise \MF\ will be forced to choose directions that have little
probability of success.
There are two main ways to specify directions at the endpoints. One way is
to supply ``hidden points'' to the \&{draw} command, as in the following
example:
$$\draw(5\to)4\to1\to3(\to6).$$
The ``$(5\to)$'' means that \MF\ is to imagine a curve that emanates from
point\penalty999\ 5, but the drawing doesn't actually begin until point 4; similarly,
the ``$(\to6)$'' means that the curve will stop at point 3 but act like it
was going on to point\penalty999\ 6. In this way \MF\ will select the same directions
at points 4 and 3 that were chosen for the curve of \fig 2-1 (``$\draw
5\to4\to1\to3\to6\to5$''), so the result will be to reproduce the segment
of \fig 2-1 that runs from 4 to 1 to 3.
The second way to specify a curve's directions is considerably more flexible:
You simply state what direction is desired. Let's consider another problem,
in order to illustrate this technique. Suppose we wish to draw a beautiful
heart shape. One approach is to start with a definite idea of what the
heart should look like, then try to get \MF\ to agree; i.e., we want \MF\ to
produce a drawing that matches the given idea. Since candy shops probably
represent the ultimate authority about the proper shape a heart
should take, the author purchased a box of chocolates on Feb.\ 14,
1979, and traced the outline of the box's shape onto a piece of graph
paper (after appropriately disposing of the box's contents). In this way
the following points were found to lie on an authentic heart:
$$\baselineskip15pt\vbox{\halign{$\hfill#$⊗\quad$#\hfill$\cr
x↓1=100;⊗y↓1=162;\cr
x↓2=200-x↓8=140;⊗y↓2=y↓8=178;\cr
x↓3=200-x↓7=185;⊗y↓3=y↓7=125;\cr
x↓4=200-x↓6=161;⊗y↓4=y↓6=57;\cr
x↓5=100;⊗y↓5=0;\cr}}$$
see \fig 2-5.
\topinsert{\rjustline{\caption 2-5(150pt){Eight points to be
used in the design of a ``heart.''}}}
The naive way to ask \MF\ for the required drawing would be
$$\&{cpen};\quad9\;\draw1\to2\to3\to4\to5;\quad\draw5\to6\to7\to8\to1;$$
\noindent but we don't expect this to be very successful, since it fails to specify
proper directions at the endpoints. In fact, it produces the lumpy shape
of \fig 2-6, something one would hardly wish to leave in San Francisco.
\MF\ will certainly have to do better than that.
$$\hbox to size{\caption 2-6(146pt){The heart will look diseased if you repeat
the mistake of \fig 2-2.}\hfill}$$
So now we come to the second way of providing the desired angles. By taking a
ruler, and drawing a straight line on the graph paper in the direction that
the correct heart shape takes at point 1, it is possible to specify the
desired direction by counting squares. The author found that the correct
line goes 40 units upwards when it goes 50 units to the right, so the direction
at point 1 is specified by the numbers 50 and 40. At point 5 the corresponding
line is not so steep, it goes down only 36 units per 50 units to the left;
the direction in this case is specified by the numbers $-50$ and $-36$. \MF\ will
adopt these directions if they are placed in braces following the names
of the points:
$$\draw1\{50,40\}\to2\to3\to4\to5\{-50,-36\};$$
this does the right half of the heart, and the left-hand portion is similar,
namely
$$\draw5\{-50,36\}\to6\to7\to8\to1\{50,-40\}.$$
When you give explicit directions in this way, any positive multiple of
the direction is satisfactory; ``$\{5,4\}$'' means the same thing as
``$\{50,40\}$'', and you could even say ``$\{1,0.8\}$''. However, the signs
of these numbers must not be changed; ``$\{-50,-36\}$'' is emphatically
{\hskip-1pt \sl not\/}
the same as ``$\{50,36\}$'', since the former means that the curve is coming to
the point from the upper right while the latter means that it is coming from
the lower left. If the direction at point 5 had been specified as $\{50,36\}$,
\MF\ would dutifully have drawn something that comes from point 4, hooks
around, and enters point 5 from the lower left; the result is best not
shown here. On the other hand the right-hand portion of the curve could
equally well have been drawn in reverse order,
$$\draw5\{50,36\}\to4\to3\to2\to1\{-50,-40\};$$
the signs are now reversed. A minus sign in the $x$ part of a direction (the
first part) means in general that the curve is going left, a plus sign means that
it is going right, and zero means that it is going vertically. A minus sign
in the $y$ part (the second part) means that the curve is going down, a plus
sign means that it is going up, and zero means that it is going horizontally.
The two \&{draw} commands above give explicit directions at the endpoints, while
taking \MF's standard directions at the interior points 2, 3, 4 and 6, 7, 8.
Unfortunately the result (\fig 2-7) is still not quite right, the transition
from 2 to 3 to 4 being somewhat disheartening. What we would like is to
bring the curve a little to the right, between 2 and 3, and a little to
the left between 3 and 4.
\topinsert{\hbox to size{\caption 2-7(147pt){Correction of the error leads
to a better shape, but still further improvement is desirable.}\hfill}}
One remedy that immediately springs to mind is to add more points. After all,
there's no obvious reason why exactly eight points should be the right number
to define this shape. It is a simple matter to look at the correct curve on
the graph paper and to add two more points where \fig 2-7 is in error, say
$$x↓9=200-x↓{10}=181;\quad y↓9=y↓{10}=97;$$
we can incorporate the new points by saying
$$\baselineskip 15pt\lpile{
\draw1\{50,40\}\to2\to3\to9\to4\to5\{-50,-36\};\cr
\draw1\{-50,40\}\to8\to7\to10\to6\to5\{50,-36\}.\cr}$$
The result in \fig 2-8 is now satisfactory.\botinsert{\rjustline{\caption
2-8(147pt){A satisfactory design can be obtained by inserting two extra points.}}}
But there is a better way, and a user of \MF\ should be encouraged to avoid
introducing new points whenever possible. The improvement comes when we
realize how points 2 and 3 were actually selected in the first place: point 2
is the topmost point, where the heart shape reaches its maximum $y$
coordinate, while point 3 is the rightmost point, where the maximum $x$
coordinate is achieved. Thus we know the correct directions at these points:
the curve is horizontal at 2 and vertical at 3. \MF\ allows curve directions
to be specified at all points, not only at the endpoints, hence the
improved solution is to say
$$\baselineskip 15pt\lpile{
\draw1\{50,40\}\to2\{1,0\}\to3\{0,-1\}\to4\to5\{-50,-36\};\cr
\draw1\{-50,40\}\to8\{-1,0\}\to7\{0,-1\}\to6\to5\{50,-36\}.\cr}$$
This leads to \fig 2-9, which is quite suitable for one's true valentine.
$$\hbox to size{\caption 2-9(135pt){Instead of specifying additional points, it
is better to specify where the curve is travelling horizontally and vertically.}
\hfill}$$
The success of this direction-specification approach suggests in fact that
we might be better off with even {\sl fewer} points. What would happen if
we tried to get by with only four points instead of eight? \fig 2-{10} is
the result of the commands
$$\baselineskip 15pt\lpile{
\draw1\{50,40\}\to3\{0,-1\}\to5\{-50,-36\};\cr
\draw1\{-50,40\}\to7\{0,-1\}\to5\{50,-36\}.\cr}$$
It turns out that this curve doesn't come up high enough for point 2, but
point 4 is very close. Thus points 2 and 8 should stay, but points 4 and 6
can be eliminated; the candy makers probably wanted point 4 to be slightly
to the left.\footnote*{Another hypothesis is that the direction at point 5
isn't quite right in the author's data (since the box was in fact crumpled
at point 5).}
$$\rjustline{\caption 2-10(135pt){This heart was drawn using only four of the
eight given data points, specifying the desired directions at points 1 and 5 and
specifying that the curve be vertical at points 7 and 3.}}$$
It isn't clear what will turn out to be the best strategy for cajoling \MF\
into drawing the shapes that its users have in mind; only time will tell.
However, one further example will help to reveal how points should be
chosen when attempting to draw curves: Let us consider the {\sl shoemaker's
problem}. The author made a tracing on graph paper of the sole of one of his
left shoes, and this led to the following data:
$$\baselineskip15pt\vbox{\halign{$#$⊗$\null=\hfill#;\;\;$⊗$#$⊗$\null=\hfill#;$⊗\quad
$#$⊗$\null=\hfill#;\;\;$⊗$#$⊗$\null=\hfill#;$⊗\quad
$#$⊗$\null=\hfill#;\;\;$⊗$#$⊗$\null=\hfill#;$\cr
x↓1⊗77⊗y↓1⊗322⊗x↓2⊗132⊗y↓2⊗220⊗x↓3⊗117⊗y↓3⊗150\cr
x↓4⊗120⊗y↓4⊗100⊗x↓5⊗131⊗y↓5⊗55⊗x↓6⊗95⊗y↓6⊗2\cr
x↓7⊗48⊗y↓7⊗60⊗x↓8⊗38⊗y↓8⊗140⊗x↓9⊗20⊗y↓9⊗200\cr}}$$
see \fig 2-{11}.
$$\rjustline{\caption 2-11(225pt){Another example, based on the shape of a shoe.}}$$
Since the sole's boundary is a closed curve without sharp corners, it is
natural to try to get \MF\ to draw it with a single \&{draw} command,
using hidden points:
$$\draw(9\to)1\to2\to3\to4\to5\to6\to7\to8\to9\to1(\to2).$$
But the result is a disaster (\fig 2-{12a}); the author's feet are somewhat
ungainly, but not so gnarled as that. The reason for this failure is what we
alluded to in connection with \fig 2-4. \MF\ needs help when you want the
curve to change directions.
Imagine that you are driving along a curved highway; sometimes you are turning left,
sometimes you are turning right, and you are at a so-called {\sl inflection
point} when you are momentarily going straight. The biggest problem in
\fig 2-{12a} occurs between 2 and 3, when the shoe sole has an inflection point
but there is no corresponding data point. Let's add one:
$$x↓{10}=125;\quad y↓{10}=184;$$
in general it is a good idea to include inflection points and to specify the
desired direction of the curve at such points.
It turns out that all ten data points in this example are either inflection
points or places where the curve travels horizontally or vertically. So the
best way to draw the shoe sole is probably to specify directions at each
point:
$$\twoline{\draw1\{1,0\}\to2\{0,-1\}\to10\{-25,-60\}\to3\{0,-1\}\to4\{18,-60\}
}{3pt}{\to5\{0,-1\}\to6\{-1,0\}\to7\{0,1\}\to8\{-30,60\}\to9\{0,1\}\to1
\{1,0\}.}$$
The result in \fig 2-{12b} does indeed capture the author's sole.\botinsert{
\vbox to 270pt{\vfill\vfill\hbox to size{a)\hfill b)\hfill}\vfill}
\ninepoint\hbox par size{{\bf Fig.\ 2-12.}\xskip \MF\ has difficulty changing
from left turns to right turns; the remedy is to specify the proper direction
at points of inflection.}}
Note that when all of the directions are specified explicitly as in this
example, the \&{draw} command could have been split up into individual
segments:
$$\baselineskip15pt\lpile{
\draw1\{1,0\}\to2\{0,-1\};\cr
\draw2\{0,-1\}\to10\{-25,-60\};\cr
\qquad\vdots\cr
\draw9\{0,1\}\to1\{1,0\};\cr}$$
the result would have been just the same.
\danger Here is how \MF\ chooses the angle at point $z↓1$ when the direction
has not been explicitly given, for a curve from $z↓0$ to $z↓1$ to $z↓2$:
Let $z↓k=(x↓k,y↓k)$, $\Delta x↓k=x↓{k+1}-x↓k$, $\Delta y↓k=y↓{k+1}-y↓k$,
and $|\Delta z↓k|↑2=(\Delta x↓k)↑2+(\Delta y↓k)↑2$. Then if $|\Delta z↓0|↑2
=0$ (i.e., if $z↓0=z↓1$), the direction is $\{\Delta x↓1,\Delta y↓1\}$
(i.e., the direction from $z↓1$ to $z↓2$). If $|\Delta z↓1|↑2
=0$ (i.e., if $z↓1=z↓2$), the direction is $\{\Delta x↓0,\Delta y↓0\}$
(i.e., the direction from $z↓0$ to $z↓1$). Otherwise the direction is
$$\{\Delta x↓0\,/\,|\Delta z↓0|↑2+\Delta x↓1\,/\,|\Delta z↓1|↑2,\;
\Delta y↓0\,/\,|\Delta z↓0|↑2+\Delta y↓1\,/\,|\Delta z↓1|↑2\},$$
which corresponds to the direction of the circle through $z↓0$, $z↓1$, $z↓2$
if these points aren't collinear. The direction computed by these rules
turns out to be $\{0,0\}$ when $z↓0=z↓2$; in this degenerate case it is
arbitrarily changed to $\{1,0\}$. When drawing a curve from $z↓1$ to $z↓2$
to $\cdots$ to $z↓n$, \MF\ will set $z↓0=z↓1$ if no hidden point is given
at the beginning, and $z↓{n+1}=z↓n$ if no hidden point is given at the end;
thus, each point of the curve has a predecessor and a successor.
\danger \exno 2.1: According to the rules in the preceding paragraph, what
curve do you get from the command ``$\draw1\to2\to2\to3$''?
\danger The actual curve drawn between $z↓1=(x↓1,y↓1)$ and $z↓2=(x↓2,y↓2)$,
when the starting direction makes an angle $\theta$ and the ending direction
makes an angle $\phi$ with respect to the straight line from $z↓1$ to
$z↓2$, can be defined in the language of complex variables by the formula
$$z(t)=z↓1+(3t↑2-2t↑3)(z↓2-z↓1)+r\cdot t(1-t)↑2\delta↓1-s\cdot t↑2(1-t)\,\delta↓2,
\quad\hbox{for }0≤t≤1.$$
Here $r$ and $s$ are special quantities explained below, while $\delta↓1$ and
$\delta↓2$ are the specified directions of the curve at $z↓1$
and $z↓2$, normalized so that $|\delta↓1|=|\delta↓2|=|z↓2-z↓1|$, namely
$$\delta↓1=e↑{i\theta}(z↓2-z↓1),\qquad \delta↓2=e↑{-i\phi}(z↓2-z↓1).$$
Whenever $r$ and $s$ are positive real numbers, the stated formula for $z(t)$ defines
a curve having the specified directions at $z↓1$ and $z↓2$; conversely,
all curves from $z↓1$ to $z↓2$ that have the specified directions, and that have
degree 3 or less as a polynomial in $t$, can be put into this form for
some $r$ and $s$. We shall call $r$ and $s$ the ``velocities'' at $z↓1$
and $z↓2$, since a large value of $r$ means that the direction remains
approximately equal to $\delta↓1$ for a long time after the curve leaves $z↓1$
and a large value of $s$ means that the direction is approximately $\delta↓2$
for a long time before the curve reaches $z↓2$. A small velocity means that
the curve may be taking a sharp turn at $z↓1$ or $z↓2$, since the directions
$\delta↓1$ or $\delta↓2$ will have comparatively little influence. \MF\ chooses
velocities by the following formulas:
$$r=\left|2\sin\chop to 0pt\phi
\over\biglp1+\leftv\cos\psi\rightv\bigrp\sin\psi\right|\,,
\qquad
s=\left|2\sin\theta\over\biglp1+\leftv\cos\psi\rightv\bigrp\sin\psi\right|\,,
\qquad \psi={\theta+\phi\over2},$$
provided that $\psi$ is not too near zero; otherwise the velocities are taken
to be $r=s=2$. These velocity formulas are rather arbitrary, but they
have been chosen so that excellent approximations to circles and ellipses
are obtained in the cases $\theta=\phi$ and $\theta+\phi=90\deg$.
Furthermore the formulas have at least one nice mathematical property,
namely the fact that they keep the curve ``in bounds'': If $\theta$ and
$\phi$ are nonnegative, the curve from $z↓1$ to $z↓2$ will lie entirely
between or on the lines $z↓1+t\delta↓1$ and $z↓1+t(z↓2-z↓1)$ and entirely
between or on the lines $z↓2-t\delta↓2$ and $z↓2-t(z↓2-z↓1)$ (for $t≥0$).
\danger Actually the velocities $r$ and $s$ are adjusted so that they aren't
too large or too small; \MF's standard mode of operation will ensure that
$0.5≤r,s≤4$.\xskip(Small values of $r$ and $s$ usually make the curve turn
too sharply at $z↓1$ or $z↓2$, while large values usually make it wander
erratically.)\xskip In the cases corresponding to Figs. \hbox{2--3} and
\hbox{2--4}, for example, we have $\theta=60\deg$ and the following
values of $\phi$, $r$, and $s$ according to the formulas above:
$$\vbox{\halign{$\hfill#$⊗\ \ $\hfill#\hfill$⊗\ \ $\hfill#\hfill$⊗\qquad
$\hfill#$⊗\ \ $\hfill#\hfill$⊗\ \ $\hfill#\hfill$⊗\qquad
$\hfill#$⊗\ \ $\hfill#\hfill$⊗\ \ $\hfill#\hfill$\cr
\phi\hskip.5em⊗r⊗s⊗\phi\hskip.5em⊗r⊗s⊗\phi\hskip.5em⊗r⊗s\cr
\noalign{\vskip 3pt}
120\deg⊗1.7321⊗1.7321⊗30\deg⊗0.8284⊗1.4349⊗-60\deg⊗2.0000⊗2.0000\cr
90\deg⊗1.6448⊗1.4245⊗0\deg⊗0.0000⊗1.8564⊗-90\deg⊗3.9307⊗3.4041\cr
60\deg⊗1.3333⊗1.3333⊗-30\deg⊗1.9653⊗3.4041⊗-120\deg⊗1.8564⊗1.8564\cr}}$$
When $\phi=0\deg$ the value of $r$ was raised by \MF\ to 0.5, otherwise
the curve would have been a straight line from $z↓1$ to $z↓2$ (not having
the correct direction at $z↓1$). \MF\ also gave the message ``{\tt Sharp turn
suppressed between points 1 and 2 (r = .0000)}'' when it drew the curve for
$\phi=0\deg$.
\penalty -300 % desirable place to break (August 25, l979)
\danger There is a way to change
\MF's velocity thresholds by altering \&{maxvr}, \&{minvr}, \&{maxvs}, and/or
\&{minvs}, as explained in Chapter 9. For example, the commands ``\&{minvr} 0.0;
\&{minvs} 0.0'' will allow arbitrarily sharp turns. This can be useful in
certain circumstances, when it is desirable to ensure that the curves
stay in bounds as explained above. Furthermore you can set $r$ and $s$ to any
desired value (in case you don't like \MF's choice) by making \&{maxvr}
and \&{minvr} be the desired $r$ and by making \&{maxvs} and \&{minvs} the
desired $s$.
\danger \exno 2.2: According to these rules, what curve do you get from the
sequence of commands ``$\&{minvr}\,0.0$; $\&{minvs}\,0.0$; $\draw1\to2\to3$''?
\enddanger
\chapterbegin 3. {Pens and erasers}
Our examples so far have drawn straight lines and curved lines using pens
shaped like circles. As you might suspect, \MF\ also has access to several other
kinds of scriveners' tools. A \MF\ user's program is supposed to select the
particular type of pen needed, and this will be the so-called current pen type until
another one is specified. The current pen type might be
$$\vbox{\halign{{\bf#},\hfill⊗ #\hfill\cr
cpen⊗``circular pen,'' as in our previous examples;\cr
hpen⊗``horizontal pen,'' having a fixed height and varying width;\cr
vpen⊗``vertical pen,'' having a fixed width and varying height;\cr
lpen⊗``left pen,'' a rectangle at the left of the current position;\cr
rpen⊗``right pen,'' a rectangle at the right of the current position;\cr
spen⊗``special pen,'' a specially defined elliptical shape;\cr
epen⊗``explicit pen,'' a fairly arbitrary shape.\cr}}$$
Chapter 1 discussed briefly the fact that pen sizes are generally expressed
in terms of \MF's $w$-variables, namely the variables named $w↓0$, $w↓1$,
$w↓2$, etc. The command ``$w↓4\,\draw1\to2\to3$'' will, for example,
draw a curve using the size-$w↓4$ pen or eraser of the current type.
Pens of types \&{cpen}, \&{hpen}, and \&{vpen} are ellipses whose axes run
horizontally and vertically. The rules by which \MF\ creates a size-$w$
pen of these types are simple:
$$\vbox{\halign{#\hfill\cr
A \&{cpen} of size $w$ has height $w$ and width $w$;\cr
an \&{hpen} of size $w$ has height $h↓0$ and width $w$;\cr
a \&{vpen} of size $w$ has height $w$ and width $v↓0$.\cr}}$$
Here $h↓0$ and $v↓0$ are the current
values of \MF\ parameters called \&{hpenht} and \&{vpenwd}.
For example, consider \fig 3-1, which was drawn with the following
\MF\ program:
\topinsert{\rjustline{\caption 3-1(45pt){Circular pen, horizontal pen, vertical
pen.}}}
$$\vbox{\halign{$#\hfill$\cr
x↓1=0;\;\;x↓2=100;\;\;x↓3=200;\;\;y↓1=y↓2=y↓3=0;\cr
\&{hpenht}\;25;\;\;\&{vpenwd}\;25;\cr
\&{cpen};\;\;75\;\draw1;\;\;\&{hpen};\;\;75\;\draw2;\;\;
\&{vpen};\;\;75\;\draw3.\cr}}$$
(Note that \&{draw} can be used for single points as well as for lines.)\xskip
The effect of such oval-shaped pens is illustrated in \fig 3-{2a}, which shows
the shoe sole of Chapter 2 drawn with an \&{hpen}, and in \fig 3-{2b}, which
shows Chapter 2's heart shape drawn with a \&{vpen}. In both cases the variable
pen size was 9 and the fixed sizes ($h↓0$ and $v↓0$) were 3.
\botinsert{\vskip 65pt\hbox to size{a)\hfill\lower 100pt\vbox to 130pt{\ninepoint
\vfill\jpar1000\hbox par 90pt{{\bf Fig.\ 3--2.}\xskip
The example shapes of Chapter 2, drawn
with a horizontal pen (a) and with a vertical pen (b).}}\quad b)\hfill}}
\yskip
Erasers can be used to ``clean off the ink'' in unwanted sections of previously
drawn lines. Any pen can be converted to an eraser by simply putting the symbol
``\hash'' after its name; for example, ``\&{cpen\hash}'' specifies a circular
eraser.
The rectangular-shaped pens \&{lpen} and \&{rpen} are most often used as erasers,
since their shapes are convenient for typical cleanup operations.
An \&{lpen} of size $w$ is a rectangle $w$ units wide and $h↓0$
units high, lying to the left of the point being drawn and centered vertically
with respect to this point. An \&{rpen} of size $w$ is similar, but it lies
just to the {\sl right} of the point being drawn. For example, \fig 3-3
shows the result of the \MF\ program
$$\vbox{\halign{$#\hfill$\cr
x↓1=0;\;\;x↓2=100;\;\;x↓3=200;\;\;y↓1=y↓2=y↓3=0;\cr
\&{hpenht}\;25;\cr
\&{cpen};\;\;150\;\draw 2;\cr
\&{lpen\hash};\;\;35\;\draw 3;\cr
\&{rpen\hash};\;\;35\;\draw 1.\cr}}$$
$$\hbox to size{\caption 3-3(50pt){Rectangular erasers used in the middle
of a large circular pen.}\hfill}$$
\danger
The ellipses you get with \&{hpen} and \&{vpen} have both horizontal and
vertical symmetry. In order to get ellipses that are tilted obliquely,
you can construct special pens (type \&{spen}). The general form of an
\&{spen} definition is slightly complicated but not hopelessly so: you say
$$\&{spen}(a,b,c,x↓0,y↓0,x↓0↑\prime,y↓0↑\prime)$$
(optionally followed by ``\hash'' if you want an eraser instead of a pen),
and the result is a pen or eraser consisting of all points $(\xi,\eta)$ such that
$$a(\xi-x↓0)↑2+b(\xi-x↓0)(\eta-y↓0)+c(\eta-y↓0)↑2≤1.$$
\vskip -6pt plus -3pt minus -3pt % negative of \dispbskip
\eject\noindent
When later drawing with this pen at point $(x,y)$, it is offset so that it
actually is placed at $(x-x↓0↑\prime, y-y↓0↑\prime)$.
The main parameters $a$, $b$, $c$ of \&{spen} must satisfy
the condition
$$b↑2<4ac.$$
Furthermore, they had better be pretty small numbers, or the pen will be
too small to be seen. When drawing with an \&{spen} (e.g., $w↓3$ $\draw1\to2$),
its ``size'' (i.e., $w↓3$) is ignored.\enddanger
\danger For simplicity let us
consider first the case $x↓0=y↓0=x↓0↑\prime=y↓0↑\prime=0$; these parameters
are generally used only for fine tuning when the discreteness of the raster
is considered.
Here is a plug-in formula for generating a pen of height $h$ and width $w$
that has been rotated counterclockwise by an angle of $\theta$ degrees: Use
$\&{spen}(a,b,c,0,0,0,0)$ where
$$a=4\,\bigglp{\cos↑2\theta\over w↑2}+{\sin↑2\theta\over h↑2}\biggrp\,,
\qquad b=(4\sin 2\theta)\bigglp{1\over w↑2}-{1\over h↑2}\biggrp\,,
\qquad c=4\,\bigglp{\sin↑2\theta\over w↑2}+{\cos↑2\theta\over h↑2}\biggrp\,.$$
(When $h$ or $w$ are small, however, you may have to play with this formula
a bit in order to avoid the effects of roundoff errors.)\xskip \fig 3-4
shows what happens when such a pen is applied to the heart shape, using
$w=9$, $h=3$, and an angle of $30\deg$.
\topinsert{\hbox to size{\caption 3-4(135pt){An oblique pen gives this
splendid valentine.}\hfill}}
\danger The quantities $a$, $b$, $c$, $x↓0$, $y↓0$, $x↓0↑\prime$, $y↓0↑\prime$
are real numbers, but the discreteness of the raster implies that \MF's
pen is actually the set of all {\sl integer} points $(\xi,\eta)$ satisfying
$a(\xi-x↓0)↑2+b(\xi-x↓0)(\eta-y↓0)+c(\eta-y↓0)↑2≤1$. Therefore it is important
for \MF\ to define its \&{cpen}s, \&{hpen}s, and \&{vpens} carefully in such
a way that they have the correct relation to the curve being drawn. Consider,
for example, a \&{cpen} of size 7, which looks like this when enlarged:
\def\pix{\vbox to 6pt{\hbox to 6pt{\vrule height 5 pt width 5pt}}}
$$\vbox{\lineskip0pt\baselineskip0pt\halign{\ctr{#}\cr
\pix\pix\pix\cr
\pix\pix\pix\pix\pix\cr
\pix\pix\pix\pix\pix\pix\pix\cr
\pix\pix\pix\pix\pix\pix\pix\cr
\pix\pix\pix\pix\pix\pix\pix\cr
\pix\pix\pix\pix\pix\cr
\pix\pix\pix\cr}}$$
To ``plot a point'' with this pen at $(x,y)$, when $x$ and $y$ are real
numbers, \MF\ first rounds to the nearest integer point $(x↑\prime,y↑\prime)$
and then blackens the pixels in locations $(x↑\prime+\xi,y↑\prime+\eta)$
where $\xi$ and $\eta$ run through the 37 square dots of the pen image:
$$(-1,3),(0,3),(1,3),(-2,2),(-1,2),\ldotss,(1,-2),(2,-2),(-1,-3),(0,-3),
(1,-3).$$
This works fine because it gives three dots above and below and to the left
and right of $(x↑\prime,y↑\prime)$; the pen has width 7 as desired. But now
consider the problem of a \&{cpen} whose width is an {\sl even} number, say 4.
The desired pattern of dots is
$$\vbox{\lineskip0pt\baselineskip0pt\halign{\ctr{#}\cr
\pix\pix\cr
\pix\pix\pix\pix\cr
\pix\pix\pix\pix\cr
\pix\pix\cr}}$$
and this shape can't be centered at an integer point $(x↑\prime,y↑\prime)$
since none of its dots is the center. \MF's remedy is to consider that the
pen shape is actually centered at $({1\over2},{1\over2})$; to plot a point with
this pen at $(x,y)$, when $x$ and $y$ are real numbers, the idea is to round
the {\sl shifted\/} point $(x-{1\over2},y-{1\over2})$ to the nearest integer
coordinates $(x↑\prime,y↑\prime)$, and then to blacken pixels $(x↑\prime+\xi,
y↑\prime+\eta)$ for the appropriate values of $(\xi,\eta)$:
$$(0,2),(1,2),(-1,1),(0,1),(1,1),(2,1),(-1,0),(0,0),(1,0),(2,0),
(0,-1),(1,-1).$$
The net effect when drawing a curve is to have a pen of width 4 that is
centered on that curve.
\danger A further complication arises from the need to make sure that exactly
the right number of integer points will satisfy the elliptical relation, since
the discretized pen should occupy precisely $w$ columns and $h$ rows, for any given
positive integers $w$ and $h$. Let $\delta(n)$ be 0 when $n$ is odd and
$\delta(n)={1\over2}$ when $n$ is even; then \MF's discrete pen of width $w$
and height $h$ is defined by $\&{spen}\biglp a,0,c,\delta(w),\delta(h),\delta(w),
\delta(h)\bigrp$ where
$$a={4\over(1+f↑2)w↑2},\qquad c={4\over(1+f↑2)\,h↑2},\qquad
f=\max\bigglp{2\delta(w)\over w},{2\delta(h)\over h}\biggrp\,.$$
\danger The most general pen or eraser shape you can get with \MF\ comes from
an \&{epen} specification, which has the form
$$\&{epen}\;(l↓k,r↓k)(l↓{k-1},r↓{k-1})\ldotsm(l↓0,r↓0).(l↓{-1},r↓{-1})\ldotsm
(l↓{-m},r↓{-m})$$
(followed by ``\hash'' if you want it to be an eraser). This denotes a pen
positioned at $(0,0)$ containing all integer points $(\xi,\eta)$ for
$l↓\eta≤\xi≤r↓\eta$ and $k≥\eta≥-m$; each $l↓\eta$ and $r↓\eta$ should be
an integer, with $l↓\eta≤r↓\eta$. If there are no points with $\eta<0$, the
``$.(l↓{-1},r↓{-1})\ldotsm(l↓{-m},r↓{-m})$'' part of this specification is
omitted; on the other hand if $m>0$ there should no space between the period
and ``$(l↓{-1},r↓{-1})$''.
\danger \fig 3-5 shows an example in which \&{epen} has been used to define
an eraser in the shape of an isosceles triangle, 5 units high and 9 units wide.
The illustration was generated by a rather simple \MF\ program:
$$\vbox{\halign{$#\hfill$\cr
x↓1=0;\;\;y↓1=-20;\;\;x↓2=50;\;\;y↓2=0;\;\;x↓3=100;\;\;y↓3=20;\cr
\&{cpen};\;\;150\;\draw2;\cr
\&{epen}\;(0,0)(-1,1)(-2,2)(-3,3)(-4,4)\hbox{\hash};\cr
\draw1\to3.\cr}}$$
$$\hbox to size{\caption 3-5(95pt){A straight line ``drawn'' with a triangular
eraser.}\hfill}$$
\danger When \MF\ draws with an \&{epen}, it ignores the pen size, just as
when it is using an \&{spen}. However, you can set \&{epenxfactor} and
\&{epenyfactor} to a value greater than 1.0 if you wish to enlarge all of your
\&{epen}s (or to a value less than 1.0 if you wish to shrink them). The expansion
or shrinkage occurs by \&{epenxfactor} in the horizontal dimension and by
\&{epenyfactor} in the vertical dimension. Two other
parameters \&{epenxcorr} and \&{epenycorr} can be set to nonzero values
$x↓0↑\prime$ and $y↓0↑\prime$ if you wish to replace $(x,y)$ by $(x-x↓0↑\prime,
y-y↓0↑\prime)$ before rounding and plotting with an \&{epen}. It should prove
interesting to create alphabets whose letters have been drawn with normal pen
motions but with abnormal \&{epen} shapes (triangles, diamonds, teardrops,
and so on).
\danger \exno 3.1: Explain how to specify an \&{lpen} of width 7 and height 5
using an \&{epen}.\xskip(When such a pen is ``plotted'' at point $(x↑\prime,
y↑\prime)$, it whitens pixels $(x↑\prime+\xi,y↑\prime+\eta)$ for $-7≤\xi≤-1$
and $-2≤\eta≤+2$.)\enddanger
Chapter 1 mentioned notations such as ``$\&{bot}↓1y↓4$'', meaning the
$y$-coordinate of the bottom of a pen of size $w↓1$ when the pen itself is
positioned at $y↓4$. These notations $\&{top}\null↓i$, $\&{bot}↓i$, $\&{lft}↓i$,
and $\&{rt}↓i$ always refer to the current pen type, and to size $w↓i$ (a
$w$-variable that must have a known value). For example, you can't say
``$\&{bot}↓1y↓4$'' unless the value of $w↓1$ has been defined earlier. If
$w↓1=9$ and the current type is \&{cpen} or \&{vpen}, ``$\&{bot}↓1y↓4$'' is
equivalent to ``$y↓4-4$''.
\yskip\noindent\exno 3.2: Describe in words the difference between the shapes
that would be drawn by the following two \MF\ programs (without typing
them into the computer):
$$\vbox{\halign{# \hfill⊗ $#\hfill$\cr
Program 1.⊗x↓1=y↓1=0;\;\;\&{hpenht}\;25;\;\;w↓1=75;\;\;\&{hpen};\;\;w↓1\;\draw1.\cr
Program 2.⊗x↓1=y↓1=y↓2=y↓3=0;\;\;w↓0=25;\;\;w↓1=75;\;\;\&{cpen};\cr
⊗\quad\&{lft}↓1x↓1=\&{lft}↓0x↓2;\;\;\&{rt}↓1x↓1=\&{rt}↓0x↓3;\;\;w↓0\;\draw2\to3.
\cr}}$$
\danger The following table gives the amount of offset produced by \&{top}, \&{bot},
\&{lft}, and \&{rt} with respect to a pen of size $w$, when $w$ is a
positive integer:
$$\vbox{\halign to size{\hfill\quad\&{#}\tabskip 0pt plus 10pt⊗
$\ctr{#}$⊗$\ctr{#}$⊗$\ctr{#}$⊗$\ctr{#}$⊗$\ctr{#}$⊗\!
$\ctr{#}$\quad\tabskip 0pt\cr
⊗\&{cpen}⊗\&{hpen}⊗\&{vpen}⊗\&{lpen}⊗\&{rpen}⊗\&{spen},\&{epen}\cr
\noalign{\vskip 3pt}
top⊗(w-1)/2⊗(h↓0-1)/2⊗(w-1)/2⊗(h↓0-1)/2⊗(h↓0-1)/2⊗y↓{\max}-y↓0↑\prime\cr
bot⊗(1-w)/2⊗(1-h↓0)/2⊗(1-w)/2⊗(1-h↓0)/2⊗(1-h↓0)/2⊗y↓{\min}-y↓0↑\prime\cr
lft⊗(1-w)/2⊗(1-w)/2⊗(1-v↓0)/2⊗-w⊗1⊗x↓{\min}-x↓0↑\prime\cr
rt⊗(w-1)/2⊗(w-1)/2⊗(v↓0-1)/2⊗-1⊗w⊗x↓{\max}-x↓0↑\prime\cr}}$$
For \&{spen} and \&{epen}, the quantities $x↓{\min}$, $x↓{\max}$, $y↓{\min}$,
$y↓{\max}$ denote the extremes of $\xi$ and $\eta$ in the discrete pen, while
$x↓0↑\prime$ and $y↓0↑\prime$ denote the offsets subtracted from the coordinates
before rounding and plotting. Note that pens of type \&{cpen}, \&{hpen}, \&{vpen},
\&{lpen}, \&{rpen} always have the property that
$$\&{top}\null↓i\&{bot}↓iy=y;$$
in other words $y↓1=\&{top}\null↓iy↓2$ if and only if $y↓2=\&{bot}↓iy↓1$. Similarly,
the operations \&{lft} and \&{rt} are inverses of each other, for types
\&{cpen}, \&{hpen}, \&{vpen}.\enddanger
\chapterbegin 4. {Running \MF}
It is high time now for you to stop reading and start playing with the computer,
since \MF\ is an interactive system that is best learned by trial and error.\xskip
(In fact, one of the nicest things about computer graphics is that your errors
are often more interesting than your ``successes.'')
The instructions in this chapter refer to the initial implementation of \MF\
with Datadisc terminals at Stanford's Artificial In\-tel\-li\-gence
Labora\-tory; similar rules will presumably hold if \MF\ has been transported
to other environments. The first thing to do (assuming that you are logged in) is
to tell the monitor
$$\hbox to size{\hskip 4em{\tt r mf}$\langle\hbox{carriage-return}\rangle$\hfill}$$
(meaning Run \MF). After \MF\ has been loaded into the machine, it will type
``{\tt*}''; this means it wants you to instruct it about what to do.
The second thing to do is type
$$\hbox to size{\hskip 4em\tt proofmode; drawdisplay;\hfill}$$
and hit \hbox{$\langle$carriage-return$\rangle$} again. The \&{proofmode}
command instructs \MF\ that you want to print hard-copy proofs of the characters
you are generating.\xskip(Such proofsheets will contain enlarged versions of the
characters together with labeled points, as in the illustrations of this
manual.)\xskip The \&{drawdisplay} command instructs \MF\ to display the
current state of what has been drawn, after every \&{draw} command.
Before doing anything else, you might as well make an intentional error,
so that you won't be quite so frightened later on when \MF\ detects
unintentional ones. Type
$$\hbox to size{\hskip 4em\tt error; another error;\hfill}$$
from now on the \hbox{$\langle$carriage-return$\rangle$}s at the end
of lines will usually not be mentioned.
\MF\ will try to figure out what you had in mind by typing this funny
line, but pretty soon it will discover that the statements make no sense.
The word ``{\tt error}'' has no special meaning in the language, so \MF\ assumes
that it is the name of one of your variables. Under this assumption, you
might be typing a statement like ``{\tt error = 5}''. But in fact you typed
``{\tt;}'' after ``{\tt error}'', and that doesn't obey the rules of \MF's
language, so you get the following response:
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
! +1.0000 error + .0000\cr
! Missing = sign, command flushed.\cr
(*) error;\cr
\ \ \ \ \ \ \ \ \ \ \ another error;\cr
\char'136\cr}}$$
The ``{\tt! Missing = sign}'' tells you what \MF\ thought was wrong about
your statement; ``{\tt command flushed}'' means that the statement has
been ignored (the error didn't hurt anything); and ``{\tt 1.0000 error +
.0000}'' is the algebraic value of the incomplete equation (in case you're
interested). The ``{\tt(*)}'' means that \MF\ was reading a line that you
typed directly at your terminal, not a line from some file. The position
where the error was detected is indicated by the fact that ``{\tt another error;}''
appears on a separate line---this second line contains text that \MF\ hasn't
looked at yet.
The ``{\tt\char'136}'' means that \MF\ wants you to respond to the error message,
but since you haven't used \MF\ before you don't know how to respond. Type
``{\tt?}'' (no \hbox{$\langle$carriage-return$\rangle$} is needed) and it will say
$$\vbox{\halign{\hbox to size{\tt#\hfill}\cr
Type <cr> to continue, <lf> to flash error messages,\cr
\ \ \ \ \ 1 or ... or 9 to ignore the next 1 to 9 tokens of input,\hskip-1em\cr
\ \ \ \ \ i or I to insert something, x or X to quit.\cr}}$$
OK, these are your options. If you type a digit ({\tt1} to {\tt9}) or the letter
``{\tt i}'', you get the ability to change what \MF\ will read next; but
these features are primarily of interest when \MF\ is processing input
from a file, so we shall discuss them later. The best thing to do at this point
is type \hbox{$\langle$carriage-return$\rangle$} (``{\tt<cr>}''),
since \hbox{$\langle$line-feed$\rangle$} (``{\tt<lf>}'') would
not give you a chance to stop and correct any future error messages.
As you might have guessed, another error will now be detected. But you probably
didn't guess what kind of error you were making, unless you've read
Chap\-ter\penalty999\ 5.
\MF\ believes that ``{\tt another error}'' is wrong because ``{\tt another}''
and ``{\tt error}'' are the names of variables, and you are trying to
multiply these variables together (as if you had written ``{\tt another*error}''
or ``{\tt another.error}''---multiplication signs need not be used in \MF\
formulas). But it is illegal to multiply two variables together unless at
least one of them has previously been given an explicit value, as we shall
see in Chapter 5, hence the error message is
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
! +1.0000 another + .0000\cr
! Undefined factor, replaced by 1.0000.\cr
(*) error; another error;\cr}}$$
(The undefined value of ``{\tt another}'' has been replaced by 1.0000 and
the machine plans to continue evaluating the algebraic expression when you
restart.)\xskip Hit \hbox{$\langle$carriage-return$\rangle$} again. And again.
Now you are once more prompted with ``{\tt*}'' and we can proceed to do some
real \MF ing. For our first trick, let's try to produce the heart shape
of \fig 2-9, but without using points 4 and 6. Type the following four
lines one at a time (without error, please):
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
x1=100; y1=162;\cr
x2=200-x8=140; y2=y8=178;\cr
x3=200-x7=185; y3=y7=125;\cr
x5=100; y5=0;\cr}}$$
don't forget the semicolons after each equation. Note that subscripted
variables like $x↓2$ are typed simply as ``{\tt x2}''; this works with
$w$-variables, $x$-variables, $y$-variables, and with constructions like
$\&{bot}↓1y↓4$ (which would be typed ``{\tt bot1y4}'').
At this point you might want to see if \MF\ was really smart enough to
figure out the value of $x↓8$ from the equation {\tt 200-x8=140}. So type
``{\tt x8;}'' and hit \hbox{$\langle$carriage-return$\rangle$}. This produces an error message we've
seen before, namely
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
! +60.0000\cr
! Missing = sign, command flushed.\cr
(*) x8;\cr}}$$
but it also reports the value of the incomplete equation $x↓8$, namely 60
(as it should be). In this way you can use \MF\ as a handy on-line computer
in case you've misplaced your pocket calculator; try typing ``{\tt sqrt 2;}''
and see what happens.\xskip(Whoops, type \hbox{$\langle$carriage-return$\rangle$} first, to get out
of error-recovery mode.)
In the midst of all these digressions about errors, we have been trying
to draw a heart shape; and in fact, we have made progress, since the shape
is almost ready to be drawn. Type
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
vpenwd 3; vpen;
{\≡9 draw 1{50,40}..2{1,0};≡\}\cr}}$$
you should now see a blip on your screen. Believe it or not, that's the
arc from point 1 to point 2. The whole heart will appear after you type
two more lines,
$$\vbox{\halign{\hbox to size{\hskip 4em \tt#\hfill}\cr
{\≡draw 2{1,0}..3{0,-1}..5{-50,-36};≡\}\cr
{\≡draw 1{-50,40}..8{-1,0}..7{0,-1}..5{50,-36};≡\}\cr}}$$
right?
Notice that the key points $(x↓i,y↓i)$ in the heart figure don't appear
on your screen (although they will appear in your proof copy). The following
statements will draw some thin auxiliary lines so that you can identify
points 2, 3, 7, and 8:
$$\hbox to size{\hskip 4em \tt w0=1; cpen; w0
draw 2..5; draw 8..5; draw 3..7;\hfill}$$
in general, some guidelines like this can be incorporated into your drawings while
you are designing characters, thereby providing convenient reference points as
you work on line. The example alphabet routines described in Appendix E include
background grids to facilitate the design process.
Now the heart shape is complete; type a period (``{\tt.}'') and hit
\hbox{$\langle$carriage-return$\rangle$}.\xskip(The period could also have been substituted for the
semicolon at the end of your previous statement.)\xskip
At this point---or perhaps
we should say ``at this period''---\MF\ prepares the proof copy of what
has been drawn, since \&{proofmode} was requested; then it gets ready for
another drawing. All of the $x$-variables and $y$-variables that have been
defined so far now become undefined again; but the $w$-variables (and any
other variables, if there had been any) retain their values. The picture
of a heart remains on your screen, but it will vanish when the result of
the next \&{draw} command is displayed.
You can test the fact that $w↓0$ is still equal to 1 by typing
$$\hbox to size{\hskip 4em \tt w0=1;\hfill}$$
\MF\ will respond ``{\tt Redundant equation.}'' You can also try typing
$$\hbox to size{\hskip 4em \tt 5w0=6;\hfill}$$
\MF\ will respond ``{\tt Inconsistent equation.}''\xskip(If you really want
to change $w↓0$ you can say, for example,
$$\hbox to size{\hskip 4em \tt new w0; 5w0=6;\hfill}$$
then $w↓0$ will become 1.2, which will be rounded to 1 if it is used as
a pen size. Things like this will be explained later in more detail.)
At this point you know enough about \MF\ to try a few experiments on your own.
Perhaps you would like to play with it before finishing this run. Just
remember to type semicolons after each statement, except that the last
statement of any particular drawing should be followed by a period. The
statements you know about so far are (i) equations, (ii) pen type specifications,
(iii) \&{draw}.
When you're all done, type ``{\tt end}'' and \MF\ should stop. Afterwards
something like ``{\tt.r xgpsyn;mfput.xgp/L}'' will show up on your terminal.
Hit \hbox{$\langle$carriage-return$\rangle$} and your proof sheets will be printed on the XGP printer.
After each run a record of what you typed and what error messages were issued
will appear on your file {\tt errors.tmp}; you can read this file to
remind yourself about any errors that you would like to avoid next time.
That finishes Experiment Number One. Are you ready for Number Two? If not,
now's a good time to take a break and put this manual down for a while.
\yyskip
Experiment Number Two should be fun, since you will learn (a) how to create a
new ``font of type'' that can be used in printing future documents, and
(b) how to get \MF\ to read from a file instead of from the terminal. The
font to be created consists of seven characters,
$$\hbox{a}=\hbox{\:;a}\quad
\hbox{b}=\hbox{\:;b}\quad
\hbox{c}=\hbox{\:;c}\quad
\hbox{d}=\hbox{\:;d}\quad
\hbox{e}=\hbox{\:;e}\quad
\hbox{f}=\hbox{\:;f}\quad
\hbox{z}=\langle\hbox{blank}\rangle,$$
each of which is 10 points square (in printers' units). We shall name the font
{\tt DRAGON}, since it can be used to typeset so-called ``dragon curves''
[cf.\ C. Davis and D. E. Knuth, {\sl J. Recreational Math.\ \bf3} (1970),
66--81, 133--149; see also
D. E. Knuth and J. C. Knuth, {\sl J. Recreational Math.\ \bf6}
(1973), 165--167]. For example, the text in \fig 4-1 can be used with
your font to produce \fig 4-2, which is a dragon curve of order 9. Another
thing you can do with {\tt DRAGON} is (i) make a border of ``{\≡dada≡\}$\ldotsm
${\≡da\par≡\}'' at the top of a page;
then (ii) type any number of pairs of lines having
the form ``{\≡cxx≡\}$\ldotsm${\≡xb\par≡\}'' followed by
``{\≡dxx≡\}$\ldotsm${\≡xa\par≡\}'', where
the {\tt x}'s represent any random mixture of {\tt e}'s and {\tt f}'s, all of
these lines having the same length as the first line; then (iii) finish up with
the line ``{\≡cbcb≡\}$\ldotsm${\≡cb\par≡\}''.\xskip(Try it!)
\topinsert{\hbox to size{\hskip 0pt plus 1000pt minus 1000pt
\vbox{\eightpoint\halign{#\hfill\cr
{\≡\:b←dragon[≡\}$\langle$your file area$\rangle$\tt]\cr
{\≡\baselineskip 0pt \lineskip 0pt≡\}\cr
{\≡zzzzzdazzda\par≡\}\cr
{\≡zzzzdfbzdfb\par≡\}\cr
{\≡zzzzceadeeada\par≡\}\cr
{\≡zzzzdfebcbcfb\par≡\}\cr
{\≡zdazcfeazzzca\par≡\}\cr
{\≡dfbzdbcbzzzdb\par≡\}\cr
{\≡ceadeazzzzcb\par≡\}\cr
{\≡dfefefa\par≡\}\cr
{\≡cbceefea\par≡\}\cr
{\≡zzdffbcb\par≡\}\cr
{\≡zzcbca\par≡\}\cr
{\≡zzzzdfadadazzzzdadazzzzdada\par≡\}\cr
{\≡zdazcfeeefeazzzcefeazzzcefea\par≡\}\cr}}
\vbox{\eightpoint\halign{\quad#\hfill\cr
{\≡dfbzdfeffbcbzdadfbcbzdadfbcb\par≡\}\cr
{\≡ceadeeefeazzzcefeazzzcefea\par≡\}\cr
{\≡dfefefefffadadefffadadefffadada\par≡\}\cr
{\≡cbceebceebceefeeefeeebceebceefea\par≡\}\cr
{\≡zzdfbzdfbzdfffefffffbzdfbzdffbcb\par≡\}\cr
{\≡zzcbzzcbzzcbceefeeefazcbzzcbca\par≡\}\cr
{\≡zzzzzzzzzzzzdfefefefbzzzzzzzdfa\par≡\}\cr
{\≡zzzzzzzzzdazcfeeebceazzzzzzzcfea\par≡\}\cr
{\≡zzzzzzzzdfbzdfefbzdfbzzzzdzzdbcb\par≡\}\cr
{\≡zzzzzzzzceadeeefazcbzzzzzcadea\par≡\}\cr
{\≡zzzzzzzzdfefefefbzzzzzzzzzcbcb\par≡\}\cr
{\≡zzzzzzzzcbceebcea\par≡\}\cr
{\≡zzzzzzzzzzdfbzdfb\par≡\}\cr
{\≡zzzzzzzzzzcbzzcb\par≡\}\cr
{\≡\vfill\end≡\}\cr}}\hskip 0pt plus 1000pt minus 1000pt}
\vskip 5pt\ninepoint\ctrline{{\bf Fig.\ 4--1.}\xskip
The \TEX\ typesetting system will produce the famous ``dragon curve'' from}
\ctrline{this input, if you create the Dragon Font described in this chapter.}}
\yyskip
In order to get ready for Experiment Number Two, prepare a file called
{\tt DRAGON.MF} that contains the following data:
{\ninepoint\baselineskip9pt
$$\def\newp{\noalign{\penalty-100\vskip2pt plus 1pt
\hbox{\hskip .5em$\langle$begin new file page$\rangle$}}}
\halign{\hskip 8pt#\hfill\cr
{\≡"The Dragon Font, created by ≡\}$\langle\hbox{your name}\rangle${\≡";≡\}\cr
{\≡fntmode; % this causes a font for the XGP to be produced≡\}\cr
{\≡tfxmode; % this causes a TEX information file to be produced≡\}\cr
{\≡titletrace; % this prints out quoted strings when they occur≡\}\cr
{\≡points=10; % change this if you want a different size font≡\}\cr
{\≡pixels=3.6; % raster units per point for TEX on the XGP≡\}\cr
{\≡w0=pixels+1; % pen size is one point plus one raster unit≡\}\cr
{\≡cpen; maxht top0 points.pixels. % tallest output in raster units≡\}\cr
\newp{\≡"a: From W to S";≡\}\cr
{\≡input drag; charcode ≡`a;≡\}\cr
{\≡w0 draw 4{1,0}..3{0,-1}.≡\}\cr
\newp{\≡"b: From W to N";≡\}\cr
{\≡input drag; charcode ≡`b;≡\}\cr
{\≡w0 draw 4{1,0}..1{0,1}.≡\}\cr
\newp{\≡"c: From N to E";≡\}\cr
{\≡input drag; charcode ≡`c;≡\}\cr
{\≡w0 draw 1{0,-1}..2{1,0}.≡\}\cr
\newp{\≡"d: From S to E";≡\}\cr
{\≡input drag; charcode ≡`d;≡\}\cr
{\≡w0 draw 3{0,1}..2{1,0}.≡\}\cr
\newp{\≡"e: From W to S and from N to E";≡\}\cr
{\≡input drag; charcode ≡`e;≡\}\cr
{\≡w0 draw 4{1,0}..3{0,-1}; draw 1{0,-1}..2{1,0}.≡\}\cr
\newp{\≡"f: From W to N and from S to E";≡\}\cr
{\≡input drag; charcode ≡`f;≡\}\cr
\noalign{\vskip 2pt}
\exno 4.1: Figure out what belongs here $\ldots$\cr
\newp{\≡"z: Blank";≡\}\cr
{\≡input drag; charcode ≡`z.≡\}\cr}$$}
\topinsert{\rjustline{\vbox to 170pt{\jpar1000\ninepoint\vfill\vfill
\hbox par 110pt{{\bf Fig.\ 4--2.}\xskip Dragon curve of order 9, typeset by
\fig 4-1 (and reduced in size).}\vfill}}}
\vskip-3pt\tenpoint\noindent
(Material beginning with the symbol ``{\≡%≡\}'' is ignored by \MF, up to the
end of a line; such comments often provide useful documentation.)\xskip Let
us hope that you don't think preparing this longish file was a drag, because
there is yet one other file that needs to be created, a shortish one called
{\tt DRAG.MF} containing the following:
$$\baselineskip9pt\def\tt{\:>}
\vbox{\halign{\hskip 9pt #\hfill\cr
{\≡% Common routine for the DRAGON characters≡\}\cr
{\≡y1=x2=points.pixels;≡\}\cr
{\≡x1=x3=y2=y4=1/2 y1;≡\}\cr
{\≡y3=x4=0;≡\}\cr
{\≡error; 2.0 intentional errors to be removed later;≡\}\cr
{\≡cpen;≡\}\cr
{\≡charht points; charwd points; chardp 0; chardw round x2;≡\}\cr}}$$
\MF\ is asked to read this file seven times by the commands ``{\tt input drag}''
in {\tt DRAGON.MF}, since {\tt DRAG.MF} contains information that is useful for all
seven characters. The {\tt charht}, {\tt charwd}, and {\tt chardp}
commands on the bottom line are for \TEX's benefit, telling the character's
height, width, and depth in units of points. The
{\tt chardw} command gives the character's approximate width in raster units.
It is more interesting to draw the characters than to supply such information,
but the information is necessary when a font is being made.
OK, now you're ready for the real action to take place. Type ``{\tt r mf}'' to
the operating system; and when you get the ``{\tt*}'', type ``{\tt input dragon}''.
The following data should soon appear on your screen:
$$\vbox{\halign{\hskip 1em\tt#\hfill\cr
(dragon.mf 1 2 3\cr
a: From W to S... (drag.mf 1 2\cr
! + 1.0000 error + .0000\cr
! Missing = sign, command flushed.\cr
p.2,l.5 error;\cr
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 2.0 intentional errors to be removed later;\cr
\char'136\cr}}$$
(If something else shows up, you might have forgotten a semicolon or
made some other typing mistake. Chapter 10 contains a complete list of error
messages in case you find \MF's remarks inscrutable.)\xskip The screen data
shown above means that \MF\ has begun to read file {\tt DRAGON.MF}; in fact
it has gotten up to page 3 and passed the quoted statement {\tt"a: From W to
S"}. Then it began to read {\tt DRAG.MF}, where an error was encountered on
page 2, line 5.\footnote*{Page numbers are one higher on Stanford's system
than they might be at other places, since the system text editor supplies a
directory page called page 1.}
We inserted an intentional error into file {\tt DRAG.MF} in order to get used
to error correction when \MF\ is reading from a file. Type ``{\tt3}'' now, just
to see what happens. When you type a digit from 1 to 9 in response to an
error, \MF\ will delete this many so-called tokens from the input. In this
case the result after deleting three tokens is
$$\vbox{\halign{\hskip 1em\tt#\hfill\cr
p.2,l.5 error; 2.0 intentional errors\cr
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
to be removed later;\cr
\char'136\cr}}$$
so you can see that the constant ``{\tt2.0}'' is considered to be a single token (not
three), and that ``{\tt intentional}'' and ``{\tt errors}'' were the other two tokens
deleted. Generally speaking, a token is a variable name or a constant or a
special character like a semicolon.\xskip(Furthermore the two dots in a
command like ``{\tt draw 1..2}'' count as a single token.)
At this point it would be a good idea for you to type ``{\tt e}''. This tells
\MF\ that you wish to terminate the present run and that you wish to make a
correction at the current place in the current file. Soon after typing
``{\tt e}'' you will find that the system text editor has started, and the cursor
shows that you are positioned at page 2, line 5 of {\tt DRAG.MF}, the place
where the error was detected. Delete this offending line from the file
and exit from the editor.
Are you continuing to follow these instructions faithfully? Please stick to
the job just a little longer, then you'll be on your own. The next thing you
should do is type ``{\tt r mf}'' again; then type
$$\hbox to size{\hskip 1em \tt input mumble\hfill}$$
(and \hbox{$\langle$carriage-return$\rangle$}). This will produce yet another error message, but it
is useful for you to learn how to recover from the wrong-file-name error
since some people don't feel that \MF's recovery procedure is completely
obvious. What you should do in response to
$$\vbox{\halign{\hbox to size{\hskip 1em\tt#\hfill}\cr
! Lookup failed on file mumble.mf.\cr
(*) input mumble\cr
\char'136\cr}}$$
is (a) type ``{\tt i}'' (meaning that you want to insert something into
what \MF\ is reading), then (b) type ``{\tt dragon}'' (the correct file
name). This ought to work.
Now you might think everything will go smoothly, but the author has planned
one more instructive error for you. The message that you get is
$$\vbox{\halign{\hbox to size{\hskip 1em\tt#\hfill}\cr
! Input page ended while scanning "a: From W to S".\cr
p.3,l.2 input drag\cr
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ; charcode `a;\cr}}$$
Actually this isn't an error, it's just a warning that an error may have occurred,
since normal usage of \MF\ will not end a file in the middle of processing a
character. We have used the short {\tt DRAG} file in this example to avoid
repeating four lines of code in seven places, but in practice it is better to
accomplish this by using subroutines (which we haven't learned yet) or by
copying the four lines into the {\tt DRAGON} file seven times using the
system text editor. Since the file ended before {\tt"a: From W to S"} was finished,
\MF\ has issued a warning that an error might have occurred. To recover, you
can either (a) hit the line-feed key now (so that \MF\ won't stop on future
errors the next six times this happens), or (b) type ``{\tt i}'' and then
type ``{\tt no pagewarning;}'' this suppresses the warning messages at the
end of file pages.\xskip(If a {\tt no} {\tt pagewarning} command had been included
near the beginning of your {\tt DRAGON.MF} file, \MF\ would not have stopped
to give you this message in the first place.)
Finally \MF\ will finish reading the last page of {\tt DRAGON.MF}; it puts a
``{\tt)}'' on your screen when this happens. You can now type ``{\tt end}'' and
the program will stop. If you have carefully followed the above instructions,
\MF's closing words to you will be
$$\vbox{\halign{\hbox to size{\hskip 1em\tt#\hfill}\cr
Images written on DRAGON.FNT\cr
TEX information written on DRAGON.TFX\cr}}$$
so you will be able to use {\tt DRAGON} as a font with your next \TEX\ manuscript.
\yskip
Note that the process of preparing a complete font is very much like the task
of writing a medium-size computer program or technical paper. It takes a
little while to get a correct computer file set up, and you have to dot the
i's and cross the t's (perhaps literally); but once you have reached this
point it is fairly easy to make changes and to develop bigger and better things.
\yskip\vfill\noindent
\exno 4.2: Since this was a long chapter, you should go outside now and get some
{\sl real\/} exercise.
\specialchapterbegin 5. {Variables, expressions, and equations}
The examples we have seen so far give some idea of what \MF\ can do in
simple cases, but in fact \MF\ knows a lot more mathematics than the
above examples imply. In this chapter we shall discuss exactly what types
of things are allowed in \MF\ equations.
The basic components of an equation are {\sl variables\/} and {\sl constants\/},
both of which take real numbers as values---they need not be integers. Since
the rules for constants are simplest, we shall discuss them first. A constant
usually has one of the forms
$$\langle\hbox{digit string}\rangle\qquad\hbox{or}\qquad\langle
\hbox{digit string}\rangle\hbox{\tt.}\langle\hbox{digit string}\rangle\qquad
\hbox{or}\qquad\hbox{\tt.}\langle\hbox{digit string}\rangle$$
denoting a number in decimal notation.\xskip(A $\langle$digit string$\rangle$
is a sequence of one or more of the ten characters {\tt0}, {\tt1}, $\ldotss$,
{\tt9}.)\xskip Or the constant may have one of the above forms preceded by
an apostrophe, in which case it represents a number in octal notation.
For example, ``{\≡≡'100≡\}'' is the same as ``{\tt64}''; ``{\≡≡'10.4≡\}''
is the same as ``{\tt8.5}'';
etc. One further form of constant is possible: A {\sl reverse
apostrophe} (i.e., a single open-quote mark) followed by any character denotes
the 7-bit code for that character. For example, ``{\≡≡`a≡\}'' is the same as
``{\≡≡'141≡\}''. This notation was used to identify the \&{charcode}s, i.e., the
font positions of the characters, in the {\tt DRAGON} example of Chapter 4.
A variable is specified in \MF\ programs by typing its so-called $\langle$\!
identifier$\rangle$, which is a sequence of one or more of the 26 letters
{\tt a}, {\tt b}, $\ldotss$, {\tt z}, with upper-case and lower-case letters
considered equivalent. However, the {\sl first\/} letter must not be
``{\tt w}'', ``{\tt x}'', or ``{\tt y}'', since these are reserved for the
subscripted variables of \MF. Furthermore some letter strings
like \&{top} and \&{draw} have a special meaning that precludes their being
used as variables; all such ``reserved words'' are listed in boldface type
in the index to this manual (Appendix I).
A variable may also have the form {\tt w}$\langle$digit string$\rangle$,
{\tt x}$\langle$digit string$\rangle$, or {\tt y}$\langle$digit string$\rangle$,
in which case it is said to be a $w$-variable (intended for pen widths),
an $x$-variable (intended for $x$ coordinates of points), or a $y$-variable
(intended for $y$ coordinates of points). We sometimes use the term $wxy$-variable
to stand for any variable of one of
these three types. Note that variables {\tt x3} and
{\tt y3} are related to each other because they are the coordinates of
point 3; but they have no connection to variable {\tt w3}. In the examples
of this manual we often use the notation $x↓3$ and $w↓3$ for what would actually be
typed ``{\tt x3}'' and ``{\tt w3}''.
\danger Actually a $wxy$-variable can have the slightly more general form
{\tt w}$\langle$index$\rangle$, {\tt x}$\langle$index$\rangle$, or
{\tt y}$\langle$index$\rangle$, where $\langle$index$\rangle$ is either a
digit string or the name of an index parameter to a subroutine, as we shall
see in Chapter 8. Thus ``{\tt xj}'' and ``{\tt yj}'' stand for the
coordinates of point {\tt j}, inside of a subroutine having {\tt j} as an
index parameter; typographic conventions like $x↓j$ and $\&{top}\null↓iy↓j$ are
used for what would actually be typed as ``{\tt xj}'' and ``{\tt top i yj}''.
\enddanger
It is important to keep in mind that variable names are composed of letters
only, unless they are $wxy$-variables. You can't have variables called
``{\tt s1}'' and ``{\tt s2}'', \MF\ will think you are talking about
$s$ times 1 and $s$ times 2. One way out is to use roman numerals like ``{\tt
si}'' and ``{\tt sii}''.
Stanford's current implementation of \MF\ will not distinguish two
different identifiers that begin with the same seven letters, unless they
have different lengths; other implementations may be even more fussy,
requiring for example that the first six letters be distinct. Therefore,
although you are allowed to invent long descriptive names for variables,
don't try to use distinct names like ``{\tt heightofa}'' and ``{\tt heightofb}''
in the same program.
No spaces should appear within the name of a variable or a constant; otherwise
\MF\ may get confused. For example, ``{\tt al pha}'' would look like two
variables, and the period in ``{\tt 3. 14}'' would look like a period instead of a
decimal point following the 3.
At the beginning of a \MF\ program, variables have no values; they get
values by appearing in {\sl equations\/}. It takes ten equations to define
the values of ten variables, and if you have given only nine equations it
might turn out that none of the ten variables has a known value. For
example, if the equations are
$$x↓0=x↓1=x↓2=x↓3=x↓4=x↓5=x↓6=x↓7=x↓8=x↓9$$
(which counts as nine equations, since there are nine $=$ signs), we don't
know what any of the $x$'s is. However, a further equation like
$$x↓0+x↓1=1$$
will cause \MF\ to deduce that all ten of these variables are equal to $1\over2$.
\MF\ always determines the values of as many variables as possible, based on
the equations it has seen so far. For example, consider the two equations
$$\baselineskip 15pt\eqalign{y↓1+y↓2+y↓3⊗=3;\cr
y↓1-y↓2-y↓3⊗=1;\cr}$$
\MF\ will deduce (correctly) that $y↓1=2$, but all it will know about $y↓2$
and $y↓3$ is that $y↓2+y↓3=1$. At any point in a program a variable is said
to be ``known'' or ``unknown,'' depending on whether or not its value can
be deduced uniquely from the equations that have been stated so
far.\footnote*{This feature makes \MF\ different from most other computer
languages; it tends to make your programs ``declarative'' more than
``imperative'' in that you say what relationships you want to achieve
instead of how you want to compute the values that achieve them.}
Sometimes you will have to be sure that a certain variable is known; for
example, when drawing a curve, the $x$- and $y$-variables for all points
on that curve must be known.
\danger You might wonder how \MF\ keeps its knowledge up-to-date based on
the partial information it receives from miscellaneous equations. The details
aren't really very important when you use the language, but they may help
in understanding some error messages. If there are $n$ variables and if
$m$ equations have appeared so far, \MF\ will classify $n-m$ of the unknown
variables as ``independent.'' The other $m$ variables are expressed as
linear combinations of the independent ones; if this linear combination has
a constant value, the variable is ``known'', otherwise it is called
``dependent.'' Every new equation, say the $(m+1)$st, can be rewritten in
the form
$$c↓0+c↓1v↓1+\cdots+c↓{n-m}v↓{n-m}=0$$
where the $c$'s are constants and $v↓1$, $\ldotss$, $v↓{n-m}$ are the
independent variables. If $c↓k=0$ for all $k>0$, the new equation is rejected;
it is either redundant (if $c↓0=0$) or inconsistent (if $c↓0≠0$). Otherwise
one of the variables $v↓k$ having maximum $|c↓k|$ is selected. This variable
ceases to be independent and the equation is used to express it in terms of
the remaining independent variables $v↓1$, $\ldotss$, $v↓{k-1}$, $v↓{k+1}$,
$\ldotss$, $v↓{n-m\,}$; several of the dependent variables might now
become known.
\danger You can experiment with \MF's equation-solving mechanism by
typing ``{\tt eqtrace;}'' near the beginning of your program. This causes
the interpreter to tell you the values of all variables when they become
known. Another way to experiment is to use the fact that \MF\ types out the
value of an expression when there is no equals sign in a statement. For
example, after ``{\tt y1+y2+y3=3; y1-y2-y3=1;}'' you can type ``{\tt y1;
y2; y3;}''---the result will be three harmless error messages in which you
learn that $y↓1=2$ and that $y↓2$ and $y↓3$ respectively have the current
values ``$-y↓3+1.000$'' and ``$y↓3$''.\xskip (In other words, \MF\ has chosen to
make $y↓2$ dependent and $y↓3$ independent.)\enddanger
\penalty -300 % nice place to break (August 25, l979)
From variables and constants you can build up more complicated formulas
called {\sl expressions\/}. In order to state the rules for expressions clearly and
completely, we shall discuss them in a rather formal manner. In order to state
them in an understandable way, we shall also discuss informal examples.
Expressions come in several flavors, depending on how complicated they are
and how they interact with their environment. A {\sl primary} expression is,
in a sense, a basic building block; it is one of the following things:
\def\⊗{\yskip\textindent{$\bullet$}\hangindent 36pt}
\def\<{$\langle$} \def\>{$\rangle$}
\⊗ a variable (whether known or unknown).
\⊗ a constant.
\⊗ \&{nrand}, denoting a random real number with the normal distribution, having
mean 0 and standard deviation 1.
\⊗ \&{sqrt} \<term\>, denoting the square root of the value of the term (e.g.,
\&{sqrt} .09 = .3). The term must have a known value.
\⊗ \&{cosd} \<term\>, denoting the cosine of the value of the term in degrees (e.g.,
\&{cosd} 60 = .5). The term must have a known value.
\⊗ \&{sind} \<term\>, denoting the sine of the value of the term in degrees (e.g.,
\&{sind}\penalty999\ 30 = .5). The term must have a known value.
\⊗ \&{round} \<term\>, denoting the value of the term rounded to the nearest
integer; an integer plus .5 is rounded upwards (e.g., \&{round} 3.14 = 3.0;
\&{round} 1.5 = 2.0; \&{round} ($-1.5$) = $-1.0$). The term must have a known value.
\⊗ \&{good}\<index\>\<term\>, denoting the value of the term rounded to the
nearest ``good'' value, depending on the value of $w↓i$ (see Chapter 7),
where $i$ is the value of the \<index\>. The term must have a known value.
\⊗ \&{lft}\<index\>\<term\>,\xskip \&{rt}\<index\>\<term\>,\xskip
\&{top}\<index\>\<term\>,\xskip or \&{bot}\<index\>\<term\>,\xskip denoting the
value of the term plus or minus a correction based on the current pen and
the value of $w↓i$ (see Chapter 3), where $i$ is the value of the \<index\>.
The term need not have a known value.
\⊗ an expression enclosed in parentheses, denoting the value of the expression
as a unit in a larger expression. For example, we will see that ``{\tt 2(u+v)}''
means something different from ``{\tt 2u+v}'', but the latter denotes exactly
the same thing as ``{\tt(2u)+v}''.
\yskip\noindent
In these rules ``\<index\>'' means either a \<digit string\>, representing
an integer subscript, or the name of an index parameter to a subroutine
(see Chapter 8); ``\<term\>'' means an expression of the second flavor,
which we shall describe next.
\penalty -400 % real nice place to break (Aug 25, 1979)
A {\sl term} expression is, in a sense, a building block for sums; it is
somewhat like a primary but it also includes products and quotients.
Formally speaking, a term is a primary followed by zero or more occurrences
of the following things as many times as possible in a given context:
\⊗ {\tt*}\<primary\>\ or {\tt.}\<primary\>\ or simply \<primary\>, denoting
the product of the value of the term so far and the value of the primary.\xskip
(At least one of these factors must have a known value; i.e., you can't say
``{\tt alpha*beta}'' when {\tt alpha}'s value is unknown unless {\tt beta}'s
value is known.\xskip When multiplication is indicated by ``{\tt.}'', no
space should appear after the dot, and the primary should not be a decimal constant.
\⊗ {\tt/}\<primary\>, denoting the value of the term so far divided by the value
of the primary.\xskip(The primary must have a known value and it must not be zero.)
\⊗ {\tt[}\<expression$↓1$\>,\<expression$↓2$\>{\tt]}, denoting $v↓1+α(v↓2-v↓1)$,
where $α$ is the value of the term so far, $v↓1$ is the value of the first
expression, and $v↓2$ is the value of the second.\xskip(Either the value of
$α$ or the value of $v↓2-v↓1$ must be known.)
\yskip\noindent
For example, ``{\tt a*b/c}'' is a term meaning $a$ times $b$ divided by $c$.
One can also write it as ``{\tt a.b/c}'' or ``{\tt a b/c}''; the space between
``{\tt a}'' and ``{\tt b}'' is essential in the last example, since
``{\tt ab/c}'' means the quotient of variable \|{ab} by variable $c$. Note
also that ``{\tt a/b*c}'' has the same meaning as ``{\tt(a/b)*c}'', not
``{\tt a/(b*c)}''. Some computer languages treat this expression one way and
some treat it the other way, but \MF\ prefers the former for two reasons:\xskip
(i) Division in \MF\ is most often used when dividing an integer by an integer,
and cases like ``\hbox{\tt2/3 c}'' are very common. It is desirable to avoid
parentheses in such common cases.\xskip (ii) This rule is easily remembered, since
terms are consistently evaluated from left to right in all cases.
The construction \<term\>{\tt[}\<expression$↓1$\>{\tt,}\<expression$↓2$\>{\tt]}
deserves special discussion since it is an operation that occurs frequently
in font design but there is no existing notation for it in traditional mathematics.
In general, ``$α[u,v]$'' means ``$α$ of the way from $u$ to $v$''; thus
``{\tt2/3[x1,x2]}'' means the value obtained by starting at $x↓1$ and
going two-thirds of the distance between $x↓1$ and $x↓2$. If $x↓1=100$ and
$x↓2=160$, this is 140; if $x↓1=160$ and $x↓2=100$ it is 120.
\yskip\noindent \exno 5.1: What is the value of $0[x↓1,x↓2]$? Of $3/2[x↓1,x↓2]$?
How would you express the value of the point midway between $x↓1$ and $x↓2$,
using this notation?
\yskip One of the interesting applications of the bracket notation is to
find the point $(x↓5,y↓5)$ where the line from $(x↓1,y↓1)$ to $(x↓2,y↓2)$
intersects the line from $(x↓3,y↓3)$ to $(x↓4,y↓4)$, assuming that
points 1, 2, 3, and 4 are already known (see \fig 5-1). The following equations
can be written, involving two variables \|{alpha} and \|{beta} that are
not used elsewhere:\topinsert{\rjustline{\caption 5-1(87pt){The coordinates of
point 5 can be readily calculated from those of points 1, 2, 3, and 4, using
\MF\ equations.}}}
$$\baselineskip 15pt\lpile{
x↓5=\|{alpha}[x↓1,x↓2]=\|{beta}[x↓3,x↓4];\cr
y↓5=\|{alpha}[y↓1,y↓2]=\|{beta}[y↓3,y↓4];\cr}$$
\MF\ will solve for \|{alpha}, \|{beta}, $x↓5$, and $y↓5$. The reasoning
behind these equations is that there is some fraction $α$ such that $x↓5$ is
$α$ of the way from $x↓1$ to $x↓2$ and $y↓5$ is $α$ of the way from $y↓1$
to $y↓2$; similarly there is some fraction relating $x↓5$ to $x↓3$ and $x↓4$
as $y↓5$ is related to $y↓3$ and $y↓4$. We don't care what $α$ and $β$ are; but
it doesn't hurt to ask \MF\ to compute more values than we really need, as
long as it also computes the desired values $x↓5$ and $y↓5$.\xskip(Note: If you
are applying this trick more than once, it is necessary to say
``{\tt new alpha,beta}''; this allows
you to reuse the same auxiliary variables \|{alpha} and \|{beta} in each
place. See Chapter 9 for the rules of {\tt new}.)
Finally we come to expressions of the third flavor: {\sl general\/}
expressions. These consist of a term followed by zero or more occurrences of
``{\tt+} \<term\>'' or ``{\tt-} \<term\>'', meaning to add or subtract the
value of the term following the plus or minus sign to or from the value of
the expression so far. A general expression can also begin with a plus sign or
a minus sign, in which case we interpret it as if it had been preceded by the
constant zero.\xskip(For example, the expression ``$-2y↓1+3y↓2$'' means
the same thing as ``$0-2y↓1+3y↓2$'', which means, ``Take zero, then subtract twice
the value of $y↓1$, then add three times the value of $y↓2$.'')\xskip
Like terms, general expressions are evaluated from left to right.
\danger Readers familiar with BNF notation may appreciate the following
summary of the syntactic rules for \MF\ variables, expressions, and
equations:
$$\def\\#1{\hbox{\<#1\>}}
\halign{\quad$#$\hfill\cr
\\{digit}←0\relv1\relv2\relv3\relv4\relv5\relv6\relv7\relv8\relv9\cr
\\{digit string}←\\{digit}\relv\\{digit string}\\{digit}\cr
\\{non wxy}←a\relv b\relv c\relv d\relv e\relv f\relv g\relv h\relv i\relv j\relv
k\relv l\relv m\relv n\relv o\relv p\relv q\relv r\relv s\relv t\relv u\relv
v\relv z\cr
\\{wxy}←w\relv x\relv y\cr
\\{letter}←\\{non wxy}\relv\\{wxy}\cr
\\{identifier}←\\{non wxy}\relv \\{identifier}\\{letter}\cr
\\{index}←\\{digit string}\relv\\{identifier}\cr
\\{variable}←\\{identifier}\relv\\{wxy}\\{index}\cr
\\{radix}←\hbox{\char'16}\relv\\{empty}\cr
\\{constant}←\\{radix}\\{digit string}\relv\\{radix}\\{digit string}
\hbox{\tt.}\\{digit string}\relv\cr
\hskip15em\\{radix}\hbox{\tt.}\\{digit string}\relv\hbox{\char'15}\\{any
character you can type}\cr
\\{unary operator}←\&{sqrt}\relv\&{cosd}\relv\&{sind}\relv\&{round}\relv
\&{good}\\{index}\relv\\{direction}\\{index}\cr
\\{direction}←\&{lft}\relv\&{rt}\relv\&{top}\relv\&{bot}\cr
\\{primary}←\\{variable}\relv\\{constant}\relv\&{nrand}\relv\\{unary operator}
\\{term}\relv(\\{expression})\cr
\\{multiplication or division sign}←{\ast}\relv.\relv\\{empty}\relv/\cr
\\{term}←\\{primary}\relv\\{term}\\{multiplication or division sign}\\{primary}
\relv\cr\hskip15em\\{term}[\\{expression},\\{expression}]\cr
\\{addition or subtraction sign}←{+}\relv{-}\cr
\\{expression}←\\{term}\relv\\{addition or subtraction sign}\\{term}\relv\cr
\hskip15em\\{expression}\\{addition or subtraction sign}\\{term}\cr
\\{equation statement}←\\{expression}=\\{expression}\relv\cr
\hskip15em\\{equation statement}=\\{expression}\cr}$$\enddanger
Before we close this discussion of expressions, a few things deserve special
emphasis:
\yskip\textindent{1)}\hang
Blank spaces, \hbox{$\langle$tab$\rangle$}s, and \hbox{$\langle$carriage-return$\rangle$}s
usually have no effect on a
\MF\ program except for the fact that they may not appear within identifiers,
constants, or file names, and the fact that they give a special meaning to
each ``{\tt.}'' that they follow. A character that has no special meaning in
the \MF\ language (e.g., ``{\tt?}'' or ``{\≡$≡\}'' or ``{\≡≡↓≡\}'') is treated as if
it were a blank
space.\xskip(Of course, blank spaces and other characters do represent themselves
when they immediately
follow a \char'15\ mark or when they appear between quotes in titles.)
\yskip\textindent{2)}\hang
The symbol ``{\tt.}'' must be used carefully when not quoted,
since \MF\ interprets it in
four different ways depending on the immediate context:
\yskip\dtextindent{i)}\hangindent38pt
If ``{\tt.}'' is followed by a blank space (or \hbox{$\langle$tab$\rangle$} or
\hbox{$\langle$carriage-return$\rangle$}), it denotes a period or ``full stop'' (the end of a \MF\
routine or subroutine).
\yskip\dtextindent{ii)}\hangindent38pt
If ``{\tt.}'' is followed by a digit (0 to 9), it
denotes a decimal point.
\yskip\dtextindent{iii)}\hangindent38pt
If ``{\tt.}'' is followed by another ``{\tt.}'', it
denotes the ``$\to$'' symbol in a \&{draw} (or \&{ddraw}) command.
\yskip\dtextindent{iv)}\hangindent38pt
Otherwise ``{\tt.}'' denotes multiplication.
\yskip\textindent{3)}\hang
You don't need parentheses in expressions like ``\&{round} $2z$'' or
``\&{sqrt} $u/v$''.\xskip$\biglp$Most computer languages require you to write
``$\&{round}(2z)$'' and ``$\&{sqrt}(u/v)$'' and even ``$\&{sqrt}(2)$''.$\bigrp$
\yskip\noindent
\exno 5.2: Does ``{\tt sqrt x1+x2}'' mean the same as\xskip (a)
``{\tt(sqrt x1)+x2}''?\xskip
(b) \penalty999\ ``{\tt sqrt(x1+x2)}''?\xskip (c) ``{\tt sqrt x1(+x2)}''?
\chapterbegin 6. {Filling in between curves}
Letter forms in modern alphabets are based primarily on the calligraphy of
fine penmen in bygone ages; but they have gone through a long evolution so that a
great many letters are quite different from what you would get using a fixed
pen. Furthermore, real pens and brushes change their shape depending on
how hard you press and on what direction you are moving, as you write or paint.
Therefore \MF\ has provisions for producing shapes in which the pen seems to
vary its proportions as it moves.
The basic way to accomplish such special effects is to use the \&{ddraw} (double
draw) command, which is like \&{draw} but you specify two curves instead of
one. When you say
$$w↓5\;\ddraw1\to2\to3\to4,\, 5\to6\to7\to8$$
(for example), the effect is essentially to take the current pen of size $w↓5$
and to draw the two curves $1\to2\to3\to4$ and $5\to6\to7\to8$, then to fill
in the space between them. This filling-in process is achieved by drawing
interpolating curves that are equally spaced between the corresponding pairs
of points 1 and 5, 2 and 6, 3 and 7, 4 and 8.
Both curves in a \&{ddraw} command are specified exactly as in \&{draw}
commands, with optional directions included in braces
at each point, and with optional
hidden points in parentheses at the beginning or end; the only proviso is
that both curves must have exactly the same number of points (not counting
hidden ones). You can say ``$\ddraw1,2$'' (which turns out to be equivalent
to ``$\draw1\to2$'' since there is only one point in each ``curve''), but
you can't say ``$\ddraw1\to2(\to3),4\to5\to6$'' (since that's a two-point
curve with a three-point one).
Suppose, for example, that you wish to fill in the heart shape discussed in
Chapter 2. Assuming that the points have been defined as in that chapter,
and assuming that \&{cpen} has been selected, the following commands can be
issued to \MF:
$$\vbox{\halign{$#$\hfill\cr
x↓9={1\over3}[x↓1,x↓3];\;\;y↓9={1\over3}[y↓1,y↓5];\cr
9\;\ddraw 1\{50,40\}\to2\{1,0\}\to3\{0,-1\}\to4\to5\{-50,-36\},\,
9\to9\to9\to9\to9;\cr
\ddraw 1\{-50,40\}\to8\{-1,0\}\to7\{0,-1\}\to6\to5\{50,-36\},\,
9\to9\to9\to9\to9.\cr}}$$
The outside boundary of the resulting shape will be precisely that of \fig 2-9,
while the interior will be solid black. \fig 6-1 indicates how \MF\ actually does
this, by showing the set of paths that a \&{cpen} of diameter 9 would take
to fill in the middle; these paths are illustrated with a \&{cpen} of
diameter 1 so that gaps are apparent.
$$\rjustline{\caption 6-1(130pt){The heart shape (or any other shape) can
be filled in by ``double drawing.''}}$$
There was, of course, no need for the example program above to define point 9
as it did; the two \&{ddraw} commands
would have worked equally well if ``$9\to9\to9\to9\to9$'' had
been replaced by ``$1\to1\to1\to1\to1$'' or ``$1\to1\to5\to5\to5$'' or a host
of other possibilities. The off-center point 9 was merely chosen to give a
nice-looking illustration that shows a bit more of how \MF\ draws curves.
\yskip\noindent\exno 6.1: On the other hand, the command
$$\twoline{9\;\ddraw 1\{50,40\}\to2\{1,0\}\to3\{0,-1\}\to4\to5\{-50,-36\},}{3pt}{
1\{-50,40\}\to8\{-1,0\}\to7\{0,-1\}\to6\to5\{50,-36\}}$$
does {\sl not\/} draw a filled-in heart shape, although it might seem at first
that it should. Why doesn't it?
\danger More precisely, suppose \&{ddraw} is given two curves that run through
the points $(z↓1,z↓2,\ldotss,z↓n)$ and $(\A z↓1,\A z↓2,\ldotss,\A z↓n)$. The
two curves $z(t)$ and $\A z(t)$ are computed as usual, then the curves
$(k/m)[z(t),\A z(t)]$ are drawn for $0≤k≤m$, where $m$ is computed in such a
way that the interior is probably (but not always) filled in by this means.
Finally, straight lines are drawn from $z↓1$ to $\A z↓1$ and from $z↓n$ to
$\A z↓n$. The value of $m$ is determined as follows: For each $j$ between
1 and $n$ we compute $\Delta x↓j=x↓j-\A x↓j$ and $\Delta y↓j=y↓j-\A y↓j$
and $m↓j$, where $m↓j$ depends on
the current pen type and size $w$ according to the formulas
$$\baselineskip30pt\ctrline{\vbox{\halign{$\ctr{#}$\quad
⊗$\ctr{#}$\quad⊗$\ctr{#}$\quad⊗$\ctr{#}$\cr
\&{cpen},\&{spen},\&{epen}⊗\&{hpen}⊗\&{vpen}⊗\&{lpen},\&{rpen}\cr
\dispstyle{\sqrt{\Delta x↑2+\Delta y↑2}\over w}⊗
\dispstyle\sqrt{\left(\Delta x↓j\over w\right)↑2\!+
\left(\Delta y↓j\over h↓0\right)↑2}⊗
\dispstyle\sqrt{\left(\Delta x↓j\over v↓0\right)↑2\!+
\left(\Delta y↓j\over w\right)↑2}⊗
\dispstyle\max\left(\left|\Delta x\over w\right|,\left|\Delta y\over h↓0\right|
\right)\,.\cr}}}$$
It follows that $\lceil m↓j+1\rceil$ equally-spaced pen images between $z↓j$ and
$\A z↓j$ would touch each other, making a connected set, if we weren't
rounding to a discrete raster.\xskip(This is the only case where the ``current
size'' is relevant for pens of type \&{spen} and \&{epen}; you should specify
a size small enough that fill-in would occur properly if the pen were a \&{cpen}
instead, but not so small that the filling-in takes extremely long.)\xskip
The actual value of $m$ is defined to be
$$\lfloor\,s\,\max(m↓1,\ldotss,m↓n)\,\rfloor+1$$
where $s$ is a ``safety factor'' that is normally equal to 2. You can
change the safety factor by saying ``\&{safetyfactor} 2.5'', for example, if
it turns out that 2.0 isn't safe enough, but actually you won't ever need to do
this unless the curves are quite unusual.
\danger \exno 6.2: How do you think the author produced \fig 6-1, using a
single \&{ddraw} command?\xskip(It was necessary to fool \MF\ into drawing
curves that didn't really fill in the interior.)\enddanger
\fig 6-2 is another example of \&{ddraw}, a sort of calligraphic effect
produced with the following program:
$$\vbox{\halign{$#\hfill$\cr
x↓1=5;\quad y↓1=10;\quad x↓2=300;\quad y↓2=-5;\cr
x↓3=0;\quad y↓3=0;\quad x↓4=298;\quad y↓4=10;\cr
\&{cpen};\quad 9\;\ddraw 1\{x↓2-x↓1,2(y↓2-y↓1)\}\to2\{1,0\},\cr
\hskip 6em 3\{1,0\}\to4\{x↓4-x↓3,2(y↓4-y↓3)\}.\cr}}$$
In this case the two \&{ddraw}n lines actually cross each other.
$$\rjustline{\vbox to 40pt{\jpar1000\ninepoint\vfill\vfill
\hbox par 100pt{{\bf Fig.\ 6--2.}\xskip Typical effect obtainable with
\&{ddraw}.}\vfill}}$$
\MF\ also provides a mechanism for dynamically varying the pen width
while drawing lines or curves, using a generalized \&{draw} command. For
example, you can say
$$\&{hpen};\quad\draw|w↓0|1\to|w↓1|2\to|w↓0|3$$
and \MF\ will draw a curve from point 1 to point 2 to point 3, starting
with an \&{hpen} of size $w↓0$ but changing the size gradually to $w↓1$ and
than back to $w↓0$ again. You can also specify directions for the curve
after the point specifications in the usual way, for example by saying
$$\draw|w↓0|1\{1,0\}\to|w↓1|2\{0,1\}\to|w↓0|3\{1,0\};$$
but we shall ignore this fact in order to simplify the following discussion.
The general rule for \&{draw} is that you can specify a pen size enclosed
in ``$|$'' signs just {\sl before} giving a point number, and you can specify
a curve direction enclosed in ``$\{$'' and ``$\}$'' just {\sl after} giving
a point number.\xskip(See Figs.\ 8--1 and 8--2 in Chapter\penalty999\
8 for examples of this feature.)
If you don't specify a new pen size at a point, the pen size from the previous
point is used; if you don't specify a new pen size at the {\sl first} point, the
so-called ``current pen size'' is used. The current pen size is set to zero whenever
a new pen type is specified, and it is changed to the value of any expression
that appears immediately before \&{draw} or \&{ddraw}; it is not changed
by values in ``$|$'' signs within a \&{draw} command. Thus, for example,
consider the commands
$$9\;\draw1\to|5|2\to3;\quad\draw4\to|8|5;$$
the pen size at point 1 is 9, at points 2 and 3 it is 5, at point 4 it is 9
again, at point 5 it is 8, and after these two statements the current
pen size is still 9.
\yskip\noindent
{\sl Important note:}\xskip This generalized version of \&{draw} is allowed
only when the pen is of type \&{hpen}, \&{vpen}, \&{lpen}, or \&{rpen};
you can't vary the size of a \&{cpen}, and it doesn't make sense to vary the
size of an \&{spen} or \&{epen}. Furthermore the changing of pen widths is
illegal in \&{ddraw} commands; in fact, as explained below, \MF\ actually
implements variable-width \&{draw} commands by reducing them to \&{ddraw}.
\danger The pen width varies smoothly according to a cubic spline function
$w(t)$ analogous to the functions $x(t)$ and $y(t)$ used to control pen motion.
Suppose we are drawing a curve from $z↓1$ to $z↓2$ to $\cdots$ to $z↓n$, and
let $z↓0$ and $z↓{n+1}$ be the hidden points at the beginning and end of the
path, where $z↓0=z↓1$ and/or $z↓{n+1}=z↓n$ if hidden points were not specified.
Similarly we will have pen sizes $s↓0$, $s↓1$, $\ldotss$, $s↓n$, $s↓{n+1}$;
if all the pen sizes are equal, the \&{draw} command proceeds as described in
Chapter 2, otherwise we have to define the variation in pen size. First the
derivatives $(s↓1↑\prime,\ldotss,s↓n↑\prime)$, which express the rates of change
in pen width as the curve passes points $(z↓1,\ldotss,z↓n)$, are determined
as follows: If no explicit pen size was given at $z↓j$, or if a ``{\tt\char'43}''
appears just before the second ``{\tt|}'' of a size specification at that point,
we let $s↓j↑\prime=0$.\xskip(The {\tt\char'43} mark signifies stable pen
size in the vicinity of that point. For example,
$$\draw|s\hbox{\tt\char'43}|1\to2\to|2/3[s,t]|3\to|t\hbox{\tt\char'43}|4\to5$$
will draw a curve with pen size $s$ between points 1 and 2, and pen size $t$
between points 4 and 5; the pen size will be stable at points 1, 2, 4, and 5,
and it will vary between points 2 and 4 in such a way that 2/3 of the change
occurs between points 2 and 3.)\xskip Otherwise let $\Delta s↓j=s↓{j+1}-s↓j$;
then $s↓j↑\prime=\Delta s↓j$ if $\Delta z↓{j-1}=0$, otherwise $s↓j↑\prime=
\Delta s↓{j-1}$ if $\Delta z↓j=0$, otherwise
$$s↓j↑\prime=\biglp\Delta s↓{j-1}/|\Delta z↓{j-1}|↑2+
\Delta s↓j/|\Delta z↓j|↑2\bigrp\,\vcenter{\hbox{\:@\char'16}}\,
\biglp 1/|\Delta z↓{j-1}|↑2+1/|\Delta z↓j|↑2\bigrp\,.$$
The pen size $s↓j(t)$, as the curve $z(t)$ of Chapter 2 is drawn from $z↓j$
to $z↓{j+1}$ for $0≤t≤1$, is defined by the formula
$$s↓j(t)=s↓j+(3t↑2-2t↑3)\Delta s↓j+t(1-t)↑2s↓j↑\prime-t↑2(1-t)\,s↓{j+1}↑\prime.$$
\penalty -300 % nice place to break (Aug. 25, 1979)
\danger When the pen size varies, a \&{draw} command is essentially reduced
to \&{ddraw} in the following way: First the functions $s(t)$, $x(t)$, $y(t)$
describing pen size and pen motion are determined as described above.
The minimum pen size, i.e., $\A s=\min(s↓1,\ldotss,s↓n)$, is also determined.
A pen of size $\A s$ will now be used to fill in the curve with the method
of \&{ddraw}; the two curves $\biglp x(t),y(t)\bigrp$ and $\biglp\A x(t),
\A y(t)\bigrp$ between which \&{ddraw}ing will take place are defined as
follows, depending on the pen type:
$$\baselineskip14pt\vbox{\halign{$\hfill#\null$⊗$\ctr{#}$\quad⊗$\ctr{#}$\quad
⊗$\ctr{#}$\quad⊗$\ctr{#}$\cr
⊗\&{hpen}⊗\&{vpen}⊗\&{lpen}⊗\&{rpen}\cr
\noalign{\vskip 3pt}
x(t)←⊗x(t)-{1\over2}\biglp s(t){-}\A s\bigrp⊗x(t)⊗x(t)⊗x(t)\cr
y(t)←⊗y(t)⊗y(t)-{1\over2}\biglp s(t){-}\A s\bigrp⊗y(t)⊗y(t)\cr
\A x(t)←⊗x(t)+{1\over2}\biglp s(t){-}\A s\bigrp⊗x(t)⊗x(t)-\biglp s(t){-}\A s\bigrp
⊗x(t)+s(t)-\A s\cr
\A y(t)←⊗y(t)⊗y(t)+{1\over2}\biglp s(t){-}\A s\bigrp⊗y(t)⊗y(t)\cr}}$$
\ddanger
If the pen motion is being transformed by means of \&{trxx}, \&{trxy}, \&{incx},
\&{tryx}, \&{tryy}, or \&{incy} (see Chapter 9), the transformation applies to
the original computation of $x(t)$ and $y(t)$ but not to the corrections by
$s(t)-\A s$ being applied here. In other words, transformations apply to
the paths taken by pens, not to the pen shapes; you can use \&{ddraw} but
not \&{draw} to get the effect of a rotated \&{hpen}.\enddanger
\chapterbegin 7. {Discreteness and discretion}
\MF\ does all of its drawing on a finite grid whose square pixels are either
black or white; it does not actually draw continuous curves, it deals
only with approximations to such curves. Such discreteness is not a severe
limitation if the resolution is fine enough, i.e., if there are
sufficiently many pixels per square unit, since physical properties of ink
will smooth out the rough edges when material is printed. In fact, the
human eye is itself composed of discrete receptors. However, the results of
\MF\ might not look very good when the resolution is coarse, unless you are
careful about how things are rounded to the raster. The purpose of this chapter
is to explain the principles of ``discreet rounding,'' i.e., tasteful
application of mathematics so that the \MF\ output will look satisfactory even
when the resolution is coarse.
The rest of this chapter is marked with dangerous bend signs, since a novice
user of \MF\ will not wish to worry about such things. However, an expert
\MF\hskip-.3pt er
will take care to round things properly even when preparing high-resolution
fonts, since the subtle refinements we are about to discuss will improve the
quality of the output when it is viewed with discerning eyes.
\danger Chapter 3 mentioned the fact that pens are digitized before curves are
drawn. This is important when low resolution is considered, otherwise vertical
lines that would be 3.4 raster units wide (say) if drawn to infinite precision
would be rounded sometimes to 3 units wide, sometimes to 4 units wide, depending
on where they happen to fall. This looks bad, so \MF\ resolves the problem
by drawing with a pen that is always 3 units wide or always 4 units wide.
\danger Chapter 3 also hinted at \MF's method of drawing a curve $\biglp x(t),
y(t)\bigrp$ as $t$ varies, namely (a) to subtract offsets $x↓0↑\prime$ and
$y↓0↑\prime$ from the $x$ and $y$ coordinates, depending on the pen being used,
thereby compensating for the fact that the pen shape might be shifted by
a non-integer amount with respect to the raster; then (b) to round
$\biglp x(t)-x↑\prime↓0,y(t)-y↑\prime↓0\bigrp$ to a sequence of integer
points $(x,y)$; and finally (c) for each integer point $(x,y)$ at which the
curve is to be ``plotted,'' the pixels $(x+\xi,y+\eta)$ are made either black
or white, depending on whether a pen or eraser is involved, for all integer
points $(\xi,\eta)$ in the pen shape.
\danger Actually \MF\ does operation (c) at higher speeds than this description
would imply, since it knows if it has reached $(x,y)$ from an adjacent point,
in which case most of the pixels $(x+\xi,y+\eta)$ are already known to be black or
white. For example, when moving a pen one step upwards, only its top edge
needs to be painted. \MF\ also gains speed by combining several horizontal
and vertical steps into a single step.
\danger What Chapter 3 failed to describe was how \MF\ chooses the sequence of
points $(x,y)$ that are to represent the curve $\biglp x(t),y(t)\bigrp$. The
rule is essentially this: The integer point $(x,y)$ is plotted if and only if
the curve $\biglp x(t)-x↓0↑\prime,y(t)-y↓0↑\prime\bigrp$ passes through the
diamond-shaped region whose four corner points are
$$\vbox{\halign{$\hfill#$⊗$\hfill#\hfill$⊗$#\hfill$\cr
⊗(x,y+{1\over2})\cr
\null\cr
(x-{1\over2},y)⊗⊗(x+{1\over2},y).\cr
\null\cr
⊗(x,y-{1\over2})\cr}}$$
This rule implies that if the curve is travelling in a basically horizontal
direction (with $x$ changing more rapidly than $y$), there is exactly
one point plotted
in each column, while if it is going in a basically vertical direction (with
$y$ changing more rapidly than $x$), there is one point plotted in each row.
Furthermore the rule leads to proper behavior at the endpoints: If a curve is broken
up into two segments, for example by inserting intermediate points in a
\&{draw} command, you won't be plotting spurious points where the two curves
join.\xskip({\sl Exception:}\xskip If an entire \&{draw} command has been processed
but no point was plotted, because for example the command was trying to draw a tiny
circle whose coordinates were all very close to $(a+{1\over2},b+{1\over2})$
for some integers $a$ and\penalty999\ $b$, \MF\ will plot one point, obtained by
rounding the first specified point $z↓1$ to integer coordinates. Each \&{draw}
therefore plots at least once.)
\danger The diamond rule for plotting curves is ambiguous in one respect: It
doesn't say what happens on the boundary of the diamond. For example, if a
horizontal or nearly horizontal curve happens to pass exactly through the
point $(x,y+{1\over2})$, when $x$ and $y$ are integers, will \MF\ plot
$(x,y+1)$ or $(x,y)$? The answer is, sometimes $(x+1,y)$ and sometimes $(x,y)$,
depending on the curve being drawn. The reason is that this behavior is
what you want, although you may not realize it at first. If the same decision
were made each time, independent of the path, the result would be undesirable because
the curves would turn out to be unsymmetrical: the left half of an `o' might look
slightly different from the right half, and the top half might look different
from the bottom. Therefore \MF's rounding rule is such that reflection
symmetries are preserved:
\yskip\textindent{a)}\hang
If $m$ is an integer then point $(x,y)$ is plotted for the curve $\biglp x(t),
y(t)\bigrp$ if and only if $(m-x,y)$ is plotted for the curve $\biglp m-x(t),
y(t)\bigrp$.
\yskip\textindent{b)}\hang
If $n$ is an integer then point $(x,y)$ is plotted for the curve $\biglp x(t),
y(t)\bigrp$ if and only if $(x,n-y)$ is plotted for the curve $\biglp x(t),
n-y(t)\bigrp$.
\yskip\noindent
(The only exceptions occur when it is essentially impossible to satisfy the
conditions, namely when the curve $\biglp x(t),y(t)\bigrp$ in (a) is a
vertical line with $x(t)=\hbox{constant}=\hbox{integer}+{1\over2}$, or similarly
when the curve $\biglp x(t),y(t)\bigrp$ in (b) is a horizontal line with
$y(t)=\hbox{constant}=\hbox{integer}+{1\over2}$.)\xskip In other words,
you can almost always ensure symmetry of the rounding operation if you simply
make the curve symmetric with respect to an integer. The precise rounding rule
used by \MF\ will not be explained here, since only the symmetry principle
above is important in practice. Symmetry is achieved by internally converting
every curve to subintervals such that some subset of the transformations
$x(t)→-x(t)$, $y(t)→-y(t)$, $x(t)↔y(t)$ produces a curve satisfying
$0≤y↑\prime(t)≤x↑\prime(t)$ throughout each subinterval. A particular
rounding rule is used for curves satisfying $0≤y↑\prime(t)≤x↑\prime(t)$, then
the rounded points are untransformed again.
\danger There is an analogous kind of symmetry that \MF\ cannot guarantee: The
result of ``$\draw1\to2\to3$'' might not be precisely the same as the result of
``$\draw3\to2\to1$'', since the rounding might be slightly different when a
curve is being drawn in the opposite direction.
\danger The fact that \MF's rounding rule preserves certain symmetries is helpful in
practice, yet it must be remembered that some asymmetry is inherent in
the fact that rounding does take place. The curve $\biglp x(t),y(t)\bigrp$ will
not, in general, look just like the curve $\biglp x(t)+{1\over3},y(t)+{1\over3}
\bigrp$, say, after rounding; so the question arises, do some curves look much
better than others? The answer is yes, but the only really critical places
seem to be where the curve reaches a horizontal or vertical extreme (when it
is travelling straight up or down, or when it is perfectly horizontal, if
only for an instant). When a curve turns a corner in such places, its
outside edge may look too flat after rounding (even when the resolution is
fairly good), unless the turning point is selected appropriately. For example,
\fig 7-1 shows three curves plotted with an \&{hpen} of width\penalty999\ 9,
when the \&{hpenht} is 3. Each of the three curves is essentially the
same, starting at $(x+10,50)$ with a slope of $\{-1,-1\}$, then coming down and
left to points $(x,0)$ where the direction is $\{0,-1\}$, then going down and
right to point $(x+10,-50)$ where the slope is $\{+1,-1\}$. The only difference
is that $x=0$ (an integer) in the lefthand curve; $x=50.4999$ (almost halfway
after an integer) in the middle curve; and $x=100.5001$ (almost halfway before an
integer) in the right-hand curve. The middle curve has an unfortunate glitch at
$y=0$, and the righthand curve looks too flat near $y=0$.
\topinsert{\rjustline{\caption 7-1(85pt){The effects of rounding are most
noticeable at the extreme points of a curve.}}}
\danger We can conclude that a curve going from right to left and back again
has a good position with respect to the raster if its extreme point occurs at
an integer, when an \&{hpen} with an {\sl odd\/} width is being used. The reason is
that an integer point is halfway between the places where rounding makes an
abrupt transition, so no obvious anomalies will appear. Similarly we get
a good position for \&{hpen}s of {\sl even} width when the extreme point occurs
at an integer plus $1\over2$, since an offset of $1\over2$ is subtracted
before rounding. Both of these cases can be summed up in one rule, that a good
case for rounding occurs if the left (or right) edge of the pen is an integer
at the extreme point. Thus, one can get good results by computing an
approximate value $l$ for the left edge of the pen and writing the equation
$$\&{lft}↓i\,x↓j=\&{round}\,l;$$
here $w↓i$ is the pen width and $x↓j$ is the $x$ coordinate of the extreme
point. Another way to achieve the same objective is to compute an approximate
value $c$ for the center of the pen at its extreme point and then to write
$$x↓j=\&{good}\null↓i\,c;$$
the \&{good} function produces the nearest integer to $c$ if the pen width
(\&{round} $w↓i$) is odd, otherwise it yields the nearest point to $c$ having
the form integer$\null+{1\over2}$. Appendix E contains examples that
show how \&{round} and \&{good} can be used to enhance the appearance of letter
shapes.\enddanger
\chapterbegin 8. {Subroutines}
When you sit down and try to design the lower case letters a to z, you will
probably discover that most letters have features in common with other ones;
for example, consider the relations between l and h, h and n, n and m, n and u.
You will therefore wish that different characters could share common portions
of \MF\ programs, with only minor variations made when these common portions are
used in different places, so that you can avoid inconsistencies and tedious
repetitions. Well, you are in luck: Common operations need to be programmed only
once, and the way to do this is much better than the ``{\tt input drag}'' solution
used in Chapter 4. {\sl Subroutines} are the answer to your problem.
Subroutines are one level of complexity up from the simplest uses of \MF, however,
so the rest of this chapter is marked off with dangerous bend signs. You should
try to play around with the rest of \MF\ for at least a little while before you dive
into the subroutine world.\xskip(Remember when you were learning other
programming languages? Your first few programs probably did not involve subroutines
or macros.)\xskip On the other hand, subroutines aren't completely mysterious,
and you will be quite ready to read on as soon as you have gotten some \MF\
experience under your belt.
\danger A subroutine begins with the reserved word \&{subroutine} and ends with
a period. More precisely, a subroutine has the form
$$\&{subroutine}\;\langle\hbox{identifier}\rangle\langle\hbox{arguments}\rangle:\;
\langle\hbox{statement list}\rangle.$$
Here the $\langle$identifier$\rangle$ is the name of the subroutine; if that
identifier has previously been used to stand for a variable or another subroutine,
its old meaning is forgotten. The $\langle$arguments$\rangle$ represent special
kinds of variables that correspond to any changeable parameters that this
subroutine will have when it is called into action by a main routine or by
another subroutine.
\danger Arguments to a subroutine can be of two kinds, ``\&{var}'' and ``\&{index}'';
the \&{var} kind represent real values, while the \&{index} kind represent
subscripts. An example should make this clear, so let's take a look at the
``\|{darc}'' subroutine of Appendix E, used to draw an elliptical double-arc
such as the left half or the right half of the letter ``o'':
$$\vbox{\halign{\hbox to size{\quad$#\hfill$}\cr
\&{subroutine}\;\|{darc}(\&{index}\,i,\&{index}\,j,\&{var}\,\|{maxwidth}):\cr
x↓1=x↓5=x↓i;\quad x↓2=x↓4=1/\|{sqrttwo}\,[x↓i,x↓j];\quad x↓3=x↓j;\cr
y↓1=y↓i;\quad y↓5=y↓j;\quad y↓3={1\over2}[y↓i,y↓j];\cr
y↓2=1/\|{sqrttwo}\,[y↓3,y↓i];\quad y↓4=1/\|{sqrttwo}\,[y↓3,y↓j];\cr
\&{hpen};\quad \draw |w↓0|1\{x↓3-x↓1,0\}
\to|{2\over3}[w↓0,\|{maxwidth}]|2\{x↓3-x↓1,y↓3-y↓1\}\to\cr
\hskip6em |\|{maxwidth}\hbox{\tt\char'43}|3\{0,y↓3-y↓1\}\to\cr
\hskip6em|{2\over3}[w↓0,\|{maxwidth}]|
4\{x↓5-x↓3,y↓5-y↓3\}\to|w↓0|5\{x↓5-x↓3,0\}.\cr}}$$
(Constructions like ``${1\over2}[y↓i,y↓j]$'' would really be typed ``{\tt
1/2[yi,yj]}''; it seems best to use special conventions when typesetting
\MF\ programs in order to make them as readable as possible.)\xskip
This particular subroutine
deserves careful study, because it is a ``real'' example that illustrates most
of \MF's conventions about subroutines in general. Therefore it will be explained
rather slowly and carefully in the following paragraphs.
\danger In other parts of a \MF\ program
containing the above subroutine, a statement like
$$\&{call}\;\|{darc}(6,7,w↓9)$$
will invoke
\|{darc} with parameters $i=6$, $j=7$, $\|{maxwidth}=w↓9$. The effect of \|{darc}
in general is that a half-ellipse will be drawn starting at point $(x↓i,y↓i)$
with an \&{hpen} of size $w↓0$; this arc will proceed to point
$(x↓j,{1\over2}[y↓i,y↓j])$ with the pen's width having grown to size
\|{maxwidth}, then it will finish at point
$(x↓i,y↓j)$ where the pen once again will come back to size $w↓0$. The
subroutine will work when $x↓i<x↓j$ as well as when $x↓i>x↓j$, and when $y↓i<y↓j$
as well as when $y↓i>y↓j$.
\danger The most important thing to remember about \MF\ subroutines is that
each routine and each subroutine has its own $x$- or $y$-variables. When \|{darc}
refers to $x↓1$ it is {\:c NOT} the same as the $x↓1$ in the routine or
subroutine that is calling \|{darc}; all \hbox{$x$-variables}
and $y$-variables have a
strictly local significance.\xskip(This is similar to the fact that $x$-variables
and $y$-variables disappear at the end of each routine that defines a single
character, i.e., they disappear when a period is reached; cf.\ the {\tt DRAGON}
example of Chapter 4.)\xskip The values of arguments (like $i$ and $j$ and
\|{maxwidth}) are also local to
a particular subroutine. On the other hand, $w$-variables and variables named by
identifiers are {\sl global}; they can be defined in one routine or subroutine
and used in another. Thus, when \|{darc} refers to $w↓0$ and to \|{sqrttwo},
these variables should have values that were defined before \|{darc} was called.
\danger A subroutine is able to refer to $x$-variables and $y$-variables of its
caller by means of index arguments. For example, suppose that \|{darc} has been
called with $i=6$; when it refers to $x↓i$, this means $x↓6$ in the calling
routine, it doesn't mean $x↓6$ local to \|{darc}. On the other hand a reference
to $w↓i$ denotes the unique variable $w↓6$.
\danger Since subroutines and their calling routines often have their own
points $x↓1$ and $y↓1$, it is desirable to have some method of naming
points meaningfully on the illustrations produced by \&{proofmode} and in
\MF's error messages. Lower case letters may be specified for this purpose in
\&{call} statements. For example, consider the following routine that
uses \|{darc} twice:
$$\vbox{\halign{\hbox to size{\quad$#\hfill$}\cr
x↓1=0;\quad y↓1=y↓3=150;\quad x↓2=50;\quad y↓2=0;\quad x↓3=100;\cr
\|{sqrttwo}=sqrt 2;\quad w↓0=3;\quad w↓1=9;\cr
\&{call}\,\hbox{\≡≡`a≡\}\;\|{darc}(2,1,w↓1);\cr
\&{call}\,\hbox{\≡≡`b≡\}\;\|{darc}(2,3,w↓1).\cr}}$$
\fig 8-1 shows the result together with the point labels.
\topinsert{\rjustline{\caption 8-1(110pt){This shape was drawn by calling
the \|{darc} subroutine twice. Points labeled 1, 2, 3 were defined in the
main routine; points whose labels begin with ``a'' were defined in the first
call of \|{darc}; and points whose labels begin with ``b'' were defined in
the second call.}}}
Here ``1'' denotes point
$(x↓1,y↓1)$ of the main routine, namely point $(0,150)$; it doesn't happen to
have been used directly for any of the curves drawn, but its coordinates $x↓1$
and $y↓1$ were used separately in \|{darc}'s calculations. The point labeled
``a5'' is point 5 inside the first call of \|{darc}, since the code {\≡≡`a≡\}
was included in this \&{call} statement. Similarly, points whose name begins
with ``b'' are the points defined in the second \&{call}. Points a1, b1, and b5
do not appear with these labels in \fig 8-1, since they coincide with points
that were already labeled.
\danger All the clues needed to understand \|{darc} have now been given; please
study that subroutine again now until you fully understand it. Incidentally,
if the value of variable \|{sqrttwo} is made
smaller than $\sqrt2=1.4142$, the \|{darc} subroutine
will draw a ``superellipse'' that opens wider than a normal ellipse does;
this effect is occasionally desirable in font design.\xskip(Cf.\ \fig 8-2.)
$$\rjustline{\caption 8-2(110pt){This shape was drawn by the same routine
as \fig 8-1, except that \|{sqrttwo} has been set equal to 1.319507911
(the value $2↑{2/5}$ recommended by Piet Hein).}}$$
\danger The argument list in a subroutine definition is either empty or it is
a list of one or more ``\&{var} $\langle$identifier$\rangle$'' or ``\&{index}
$\langle$identifier$\rangle$'' entries enclosed in parentheses and separated
either by commas or by ``{\tt)(}'' pairs.\xskip(Subroutine \|{darc}'s definition
might have begun
$$\&{subroutine}\;\|{darc}(\&{index}\,i)(\&{index}\,j)(\&{var}\,\|{maxwidth}):$$
some people prefer this syntax.)\xskip Formally speaking, we have the following
BNF definition:
$$\def\\#1{\hbox{\<#1\>}}
\vbox{\halign{$#\hfill$\cr
\\{arguments}←\\{empty}\relv(\\{argument list})\cr
\\{argument list}←\\{argument}\relv\\{argument list},\\{argument}\cr
\hskip 10em\relv\\{argument list})(\\{argument}\cr
\\{argument}←\&{var}\,\\{identifier}\relv\&{index}\,\\{identifier}\cr}}$$
A \&{call} command has a similar format. The parameters in a \&{call} must
agree in number and kind with the arguments in the corresponding subroutine
definition.
\danger \exno 8.1: Write a subroutine that will draw \fig 2-3 when it is
called by the following driver program:
$$\baselineskip14pt\lpile{
x↓1=y↓1=y↓2=0;\quad x↓2=150;\cr
\&{call}\;\|{curve}(60,120,1,2);\cr
\&{call}\;\|{curve}(60,90,1,2);\cr
\&{call}\;\|{curve}(60,60,1,2);\cr
\&{call}\;\|{curve}(60,30,1,2);\cr
\&{call}\;\|{curve}(60,0,1,2).\cr}$$
\danger Another example---this one contrived---should further clarify the
general idea of index arguments. Consider the program
$$\vbox{\halign{\hbox{$#\hfill$}\cr
\&{subroutine}\;\|{sub}(\&{index}\,i):\cr
\ldotsm;\quad\&{call}\,\hbox{\≡≡`a≡\}\;\|{subsub}(i,1);\quad\ldotss\,.\cr
\noalign{\vskip 3pt}
\&{subroutine}\;\|{subsub}(\&{index}\,i,\&{index}\,j):\cr
\ldotsm;\quad\draw i\to j\to2;\quad\ldotss\,.\cr
\noalign{\vskip 3pt}
\&{call}\,\hbox{\≡≡`b≡\}\;\|{sub}(3).\cr}}$$
Can you figure out what points the ``$\draw i\to j\to2$'' command
refers to in \|{subsub},
before the answer is revealed in the next sentence of this paragraph?\xskip
Answer (don't peek):\xskip inside \|{sub}, ``$i$'' refers to point 3 of the
main routine and ``1'' refers to local point b1; there\-fore
inside \|{subsub}, ``$i$'' and
``$j$'' refer to 3 and b1, while ``2'' refers to local point ba2.\xskip
(Note the concatenation of labels since \|{subsub} is being used as a
sub-subroutine.)\xskip If for some reason \|{subsub} forgot to define its local
variable $x↓2$, you would get the error message ``{\tt Variable xba2 is undefined}''
at the time ``$\draw i\to j\to2$'' was being interpreted.
\danger This example reveals two other things about subroutines:\xskip(1)
It is permissible for different subroutines to have arguments with the
same name. In fact, the name of an argument may also be identical to the
name of a global variable or even to the name of another subroutine;
that identifier refers to the appropriate argument,
within the subroutine being defined, but
it reverts to its global meaning when the subroutine definition ends.\xskip
(2)\penalty999\
It is permissible to \&{call} subroutines that have not yet been defined.\xskip
(Note that ``\&{call} {\≡≡`a≡\} \|{subsub}'' appeared in the program before
\|{subsub} was known to be the name of a subroutine.)\xskip In fact, it is
even permissible for a subroutine to call itself, if you are careful to avoid
infinite recursion, provided that the subroutine has no arguments (see below).
However, when a \&{call} is actually being interpreted, the called subroutine
definition must already have appeared. It is easy to understand this
rule if you understand how subroutines are actually implemented: When \MF\
sees a subroutine definition, it stores away the text for future use; then
when a \&{call} statement appears, the text of the subroutine is fed through
\MF's reading mechanism in place of the text of the \&{call}.
\danger Since the previous paragraph mentions the possibility of recursion,
an alert reader will have guessed that \MF\ has the capability of interpreting
statements {\sl conditionally}, i.e., performing certain computations only
if certain relations hold. Yes, alert reader, there is an \&{if} statement.
It has two general forms,
$$\baselineskip16pt\vbox{\halign{\hfill#\quad⊗#\hfill\cr
⊗\&{if} \<relation\>: \<statement list\>; \&{fi}\cr
or⊗\&{if} \<relation\>: \<statement list$↓1$\>; \&{else}: \<statement list$↓2$\>;
\&{fi}\cr}}$$
where the first is treated like the second but with \<statement list$↓2$\>\ empty.
A \<relation\>\ has the form
$$\hbox{\<expression$↓1$\>\ \<relop\>\ \<expression$↓2$\>}$$
where \<relop\>\ is one of the six relational operator symbols $=$, $<$, $>$,
$≠$, $≤$, $≥$. The meaning of an \&{if} statement is that \<statement list$↓1$\>\
is interpreted if the relation is true, \<statement list$↓2$\>\ is interpreted
if the relation is false, and the error message ``{\tt Indeterminate relation}''
results if the relation cannot be decided due to unknown variables. The relation
``$z=z$'' is known to be true whether $z$ is known or not, but the relation
``$z>0$'' is indeterminate unless $z$ is known.\xskip {\sl N.B.: Don't forget the\/\
\&{fi} that closes the\/\ \&{if}.}
\danger When a subroutine is called, the current pen type and current pen size
are remembered so that they can be restored when the subroutine is
finished. The ``control bits'' described in Chapter 9, governing tracing
and output modes, are also saved and restored across \&{call}s. The subroutine
must specify a new current pen type and current pen size before it draws
any curves or uses some other operation that depends on the current pen type,
since \MF\ considers the pen type to be undefined upon entry to a subroutine.
This restriction tends to catch careless errors; you can override it, if
necessary, by saying ``\&{no} \&{penreset}''.
\ddanger Let us close this chapter with an example of a recursive subroutine.
Devotees of structured programming who have the conventional misunderstanding
of that term will rejoice in the fact that \MF\ has no \&{go} \&{to} statement;
but such people might not be so happy about the fact that there is no \&{while}
statement either. In the comparatively few cases where iterations are
desirable in font design, there is no reason to despair, since iteration is
easy to achieve via recursion (even when we must live with \MF's restriction that
recursive procedures cannot have arguments). The following subroutine draws
an indeterminate number of straight vertical lines, from point $(a+kd,b)$ to
point $(a+kd,c)$ for $k=0$, 1, $\ldotss$, as long as $a+kd≤t$.
$$\vbox{\halign{\hbox to size{\quad$#\hfill$}\cr
\&{subroutine}\;\|{for}(\&{var}\,a,\&{var}\,b,\&{var}\,c,\&{var}\,d,\&{var}\,t):\cr
\&{new}\;\|{aa},\|{bb},\|{cc},\|{dd},\|{tt};\cr
\|{aa}=a;\quad \|{bb}=b;\quad\|{cc}=c;\quad\|{dd}=d;\quad\|{tt}=t;\cr
\&{call}\,\hbox{\≡≡`a≡\}\;\|{loop}.\cr
\noalign{\vskip 3pt}
\&{subroutine}\;\|{loop}:\cr
\&{if}\;\|{aa}≤\|{tt}:\;x↓1=x↓2=\|{aa};\;y↓1=\|{bb};\;y↓2=\|{cc};\cr
\hskip 6em\&{cpen};\;w↓0\;\draw1\to2;\cr
\hskip 6em x↓3=\|{aa}+\|{dd};\;\&{new}\,\|{aa};\;\|{aa}=x↓3;\cr
\hskip 6em\&{call}\,\hbox{\≡≡`b≡\}\;\|{loop};\cr
\&{fi}.\cr}}$$
Note the use of \&{new} to emulate an operation that would be written
``$\|{aa}\mathrel:=\|{aa}+\|{dd}$'' in more conventional programming languages.
\ddanger \exno 8.2: Continuing this example, suppose that
the main routine is ``\&{proofmode}; $w↓0=3$; \&{call} {\≡≡`c≡\}
\|{for}$(0,0,100,50,150)$.'' What labels would appear on the eight points between
which the four vertical lines are drawn?
\enddanger
\chapterbegin 9. {Summary of the language}
A \MF\ program consists of sections, each of which is terminated by
a period.\xskip(This period is followed immediately by a
\hbox{$\langle$carriage-return$\rangle$} or by a blank space,
as explained in Chapter 5, so that it is readily distinguishable
from a decimal points or a multiplication signs or the ``$\to$'' of a \&{draw} or
\&{ddraw} command.)\xskip The period that terminates the final section is
followed by the word ``\&{end}''; this terminates the program.
The $x$-variables and $y$-variables of each section are ``local'' to that section,
in the sense that $x↓1$ (say) in one section has no relation to $x↓1$ in another;
but the other variables are shared by all sections. Within a section, you write
one or more ``statements'' separated by semicolons.
A typical \MF\ program starts out with a section in which you define important
variables that will be used for all the characters you intend to generate,
followed by sections for any subroutines you wish to define, followed by
sections that draw each character. This order of sections is not absolutely
necessary, but it is suitable for most purposes.
Appendix E contains examples of complete \MF\ programs used to define characters
in the ``Computer Modern'' family of fonts designed by the author for use in
his books {\sl The Art of Computer Programming}. Basic \MF\ setups for
designing new characters or modifying the designs of existing ones,
as well as for producing new fonts with particular settings
of the variable parameters, are described in that appendix.
The present chapter is intended to serve as a concise and precise summary of all
of \MF's features. We have discussed most of these things already,
but there are also a few more bells and whistles that you may want to
use. The idea is now to get it all together.
\yyskip
\ninepoint As stated above, a \MF\ program has the general form
$$\hbox{\<section$↓1$\>\<section$↓2$\>$\ldotsm$\<section$↓m$\>\ \&{end}}$$
where each \<section\>\ is either a subroutine definition or
has the form of a \<statement list\>\ followed by a period, namely
$$\hbox{\<statement$↓1$\>; \<statement$↓2$\>; $\ldotss$; \<statement$↓n$\>.}$$
The main question remaining is therefore, ``What is a \<statement\>?'' The
various kinds of statements are enumerated below, with a bullet symbol ($\bullet$)
in front of each kind.
\def\⊗#1 #2.{\yskip\textindent{$\bullet$}#1\hskip 2em #2.\par\yskip\noindent\!}
\⊗{\<empty\>} A null statement.
One of the things you can do with \MF\ is nothing. The null statement does this.
\⊗{\<equation\>} An equation between variables.
Equations, which consist of two or more
\<expression\>s separated by ``='' signs, are discussed thoroughly in Chapter 5.
Each equals sign leads to the elimination
of one independent variable, since an expression can be reduced to a linear
combination of independent variables, unless the equation is redundant or
inconsistent with respect to previous equations. The purpose of equations is to
state the relationships you wish the variables of your program to satisfy;
you must give enough equations so that \MF\ can solve them uniquely, obtaining
known values for all variables that it needs to know.
\⊗{\&{new} \<variable list\>} Undefines variables.
A \<variable list\>\ consists of one or more variable names separated by commas;
for example, you can say ``\&{new} \|{alpha}, \|{beta}, $x↓3$, $y↓2$''. Sometimes
you will have used equations to define the value of some variable that you now wish
to redefine. By listing this variable in a \&{new} statement, its old value
becomes forgotten.\xskip(You should do this only when the variable has a known
value, or when it is already \&{new} and you are just trying to be safe---e.g.,
in a subroutine when the variable is to be used for temporary storage.)
\⊗{\<pen name\>\<optional \hash\>} Specifies the current pen or eraser type.
At the beginning of each routine or subroutine, the current pen type is
undefined, and you must define it before \&{draw}ing anything or using an
expression like \&{top} that requires knowledge of the pen type. The \<pen name\>\
statement defines the current pen type, and changes the pen to an eraser
if a ``\hash'' appears. It also resets the current pen size to
zero; this is a useless pen size, so you should probably specify
a useful value on the next \&{draw} or \&{ddraw} command. Allowable pen
names are \&{cpen}, \&{hpen}, \&{vpen}, \&{lpen}, \&{rpen}, \&{spen}, and \&{epen},
as described in Chapter\penalty999\ 3. An \&{spen} or \&{epen} should be further specified,
according to the rules in that chapter. However, if you wish the \&{spen} or
\&{epen} to have the same specs as the most recent one that \MF\ has generated
as it was interpreting your program, you can omit the specification and
simply say ``\&{spen}'' or ``\&{epen}''.
\⊗{\<drawing command\>} Draws a line or curve.
The general format of a \<drawing command\>\ is either
$$\baselineskip15pt\vbox{\halign{\hbox to 0pt{\hskip0pt minus10000pt#\qquad}⊗#\hfill
\cr
⊗\<expression\>\ \&{draw} \<path\>\cr
or⊗\<expression\>\ \&{ddraw} \<path$↓1$\>, \<path$↓2$\>\cr}}$$
where the \<expression\>\ represents the new pen size; this can be
omitted if the current pen size is to be used. The rules for \&{draw}
and \&{ddraw} are explained in Chapters 2 and 6, so we shall merely summarize
here the precise rules for a \<path\>. In general a \<path\>\ has the form
$$\hbox{\<hidden beginning\>\<point$↓1\rangle\to\langle$point$↓2\rangle\to\,\,\cdots
\,\,\to\langle$point$↓n\rangle\langle$hidden ending\>}$$
for some $n≥1$, where the two paths in \&{ddraw} must have the same length $n$.
The \<hidden beginning\>\ is either empty, representing a copy of \<point$↓1$\>,
or it has the form ``(\<point$↓0\rangle\to)$''; the \<hidden ending\>\ is either
empty, representing a copy of \<point$↓n$\>, or it has the form ``($\to\langle
$point$↓{n+1}\rangle)$''. The form of a \<point\>\ is
$$\hbox{\<optional pen size\>\<index\>\<optional direction\>}$$
where \<optional pen size\>\ is either empty (meaning to use the pen size at the
previous point, or to use the current pen size if this is the first point)
or it has one of the two forms
$$|\hbox{\<expression\>}|\qquad\hbox{or}\qquad|\hbox{\<expression\>\hash}|.$$
The \<expression\>\ denotes the desired pen size at the point; the \hbox{\hash}
denotes stable pen size in the point's neighborhood, otherwise the pen size
will change at a rate determined as explained in Chapter 6. A \hbox{\hash} is
implied when the \<optional pen size\>\ is empty. The \<optional pen size\>\
{\sl must\/} be empty for all points in the paths of a \&{ddraw} command. The
\<optional direction\>\ is either empty (meaning to let \MF\ choose the direction
in its standard way, as explained in Chapter 2), or it has the form
$$\hbox{$\{\langle$expression$↓1\rangle,\langle$expression$↓2\rangle\}$}.$$
In this case, if $x$ is the value of \<expression$↓1\rangle$ and $y$ the value
of \<expression$↓2\rangle$, the curve will move toward a position that is
$x$ units to the right and $y$ units upwards, when it passes the current point.
\⊗{{\tt"}\<any desired title\>{\tt"}} Names the font or the character being drawn.
(Not allowed in subroutines. The title can be any string of characters other
than quote marks or \hbox{$\langle$carriage-return$\rangle$}s.)\xskip This statement has several
effects:\xskip(i) The first time \MF\ interprets a title statement, it saves
the string you have specified as the so-called main title that will appear
in the computer file if you generate a font.\xskip(ii) If you are in
\&{titletrace} mode, the title will be printed on your screen, as a sort of
progress report.\xskip(iii) The title will appear on the proofsheet output if
the current routine is used to draw a character in proof mode.\xskip(iv) A
warning message will be printed (mentioning this title) if \MF\ scans the
end of a file page before the current section ends, unless you are in {\bf no
pagewarning} mode.
\⊗{\<conditional statement\>} Chooses between alternative programs.
A construction like
\par\yskip\ctrline{\&{if} \<relation\>: \<statement$↓1$\>; \<statement$↓2$\>;
\&{else}: \<statement$↓3$\>; \<statement$↓4$\>; \&{fi}}\yskip\noindent
will interpret
\<statement$↓1$\>\ and \<statement$↓2$\>\ if the relation is true, \<statement$↓3$\>\
and \<statement$↓4$\>\ if the relation is false. Chapter 8 gives the general rules.
\⊗{\&{call} \<optional letter\>\<subroutine name\>\<parameters\>} Invokes a
subroutine.
The \<optional letter\>\ is either empty or an expression of the form
``{\≡≡`≡\}\<lower case letter\>''; the \<subroutine name\>\ is the identifier
of a subroutine that has already been defined; and the \<parameters\>\ part
is either empty, or it is a parenthesized list of \<expression\>s to be
substituted for \&{var} arguments, and/or \<index\>es to be substituted for
\&{index} arguments, separated by commas or ``)('' pairs. The parameters must
be in the same order as the corresponding arguments, and there must be
exactly as many parameters as arguments.
\⊗{\<parameter name\>\<expression\>} Defines a \MF\ parameter.
A parameter statement like this is used to communicate values that \MF\ occasionally
needs for its work. The parameters have ``default'' values when \MF\ begins;
but once you change a parameter with an explicit parameter statement, its former
value is forgotten. The value of the \<expression\>\ must be known at the time
this statement is interpreted. Here is a list of the parameter names understood
by the present implementation of \MF:
\def\¬{\yskip\hangindent 38pt$ $}
\¬\&{trxx}, \&{trxy}, \&{incx}, \&{tryx}, \&{tryy}, \&{incy} are used to
rotate, translate, and/or expand or shrink the curves that \MF\ draws. After
computing the functions $x(t)$ and $y(t)$ according to the rules described
in Chapters 2 and 6, the actual curve that will be
plotted---before subtracting the offsets
$x↓0↑\prime$ and $y↓0↑\prime$ and before rounding, and before reducing
variable-size \&{draw} to \&{ddraw}---is
$$\biglp α↓{xx\,}x(t)+α↓{xy\,}y(t)+α↓x,\,α↓{yx\,}x(t)+α↓{yy\,}y(t)+α↓y\bigrp,$$
where $α↓{xx}$, $α↓{xy}$, $α↓x$, $α↓{yx}$, $α↓{yy}$, $α↓y$ are the respective
current values of the six parameters stated.\xskip(The default values are, of
course, \&{trxx} 1; \&{trxy} 0; \&{incx} 0; \&{tryx} 0; \&{tryy} 1; \&{incy}
0.)\xskip By setting \&{trxy} to 0.15, your drawings will be
{\sl slanted to the right as in the letters you are now reading\/}; those letters
were made with the same \MF\ programs that generated the unslanted letters
you are now reading, changing only the setting of \&{trxy}. The six
transformation parameters do not affect the size or shape of pens, only the
locations of their motions.
\¬\&{charwd}, \&{charht}, \&{chardp}, \&{charic} are used to specify the width,
height, depth, and italic correction for a character, in units of printers'
points. These parameters are zero by default, and they are reset to zero at the
end of every routine when a character is output. The parameters are used when
preparing a font information file to be used by \TEX; they do not affect the
actual appearance of a character in a font.
\¬\&{epenxfactor} and \&{epenyfactor} (normally 1.0) are used to enlarge or
smallify the dimensions of an \&{epen} when an explicit pen is specified. These
parameters should change in proportion to the number of pixels per inch when
you are designing fonts for a variety of machines.
\¬\&{epenxcorr} and \&{epenycorr} (normally 0.0) are used as the
offsets $x↓0↑\prime$ and $y↓0↑\prime$ when an explicit pen (\&{epen}) is
specified.
\¬\&{safetyfactor} (normally 2.0) is used to govern the number of curves plotted
by \&{ddraw} when it is filling in between two curves (see Chapter 6).
\¬\&{minvr}, \&{maxvr}, \&{minvs}, \&{maxvs} (normally 0.5, 4.0, 0.5, 4.0) are
used as velocity thresholds when computing the spline curves corresponding to a
path, as explained in Chapter 2.
\yskip\noindent
The following parameters are rounded to the nearest integer before \MF\ uses them:
\¬\&{hpenht} and \&{vpenwd} (normally 1) are used to specify the height of each
\&{hpen} and the width of each \&{vpen}. It is best to adjust these infrequently,
since \MF\ has to recompute its accumulated pen information when they are reset.
\¬\&{nseed} (normally set to a value based on the time of day, so that it will
be different every time you run \MF) is used to start the pseudo-random number
generator that produces the values of \&{nrand}. By setting \&{nseed} to a
particular integer at the beginning of your program---any integer will do---you
can guarantee that the same sequence of \&{nrand} values will occur each
time the program is run.
\¬\&{maxht} specifies the height (in pixels)
of the tallest character in a font being generated for the XGP. This
parameter, which is initially zero,
must be set before the first character of the font has been output.
\¬\&{charcode} is used to specify the 7-bit number of a character being output
to a font. This parameter has the invalid value
$-1$ when \MF\ begins, and it is reset to $-1$
after each character is output. No character will be output unless the \&{charcode}
parameter has been set to a number between 0 and 127, inclusive, and it should
be distinct from the numbers of other characters output.
\¬\&{chardw} specifies the current character's width (in pixels), when a font
is being produced for the XGP printer; this information is also used when
preparing font information for \TEX\ to use with the XGP. Like \&{charwd},
this parameter is zero for each character until you set it explicitly. There
is no automatic connection between \&{charwd} and \&{chardw}.
\¬\&{crsbreak} specifies the $y$ coordinate at which a tall character will be
broken into two pieces when preparing it for an Alphatype CRS font; the
upper piece will contain raster positions for rows $≥y$, the lower piece will
contain rows $<y$. This parameter is normally set to an essentially infinite
value, which is restored when a character is output, so that no characters
will be broken unless a \&{crsbreak} has been explicitly specified.
\¬\&{dumplength} (normally 1000) is the number of characters before ``{\tt ETC}''
that will be displayed in error messages when \MF\ stops in the middle of
a subroutine. If you make an error in a long subroutine, you may need to increase
this parameter in order to see where the error occurred.
\¬\&{dumpwindow} (normally 32) is the maximum number of characters displayed on
each line of an error message when identifying the current program location.
\yskip
\textindent{$\bullet$}\<control code\>\hskip 2em Sets a ``control bit.''\par
\yskip\textindent{$\bullet$}\&{no} \<control code\>\hskip 2em
Unsets a ``control bit.''\par\yskip\noindent\!
These statements are used to turn on or turn off certain actions that \MF\ is
capable of doing. \MF\ maintains a so-called control word, a set of bits that
govern whether or not certain optional actions are taken;
after a subroutine call, this control word is restored
to the state it had before entering the subroutine.
Initially the bits for \&{modtrace}, \&{pagewarning}, and \&{penreset} are
turned on, all the others are off. Here is a list of the control codes
understood by the present implementation of \MF:
\¬\&{eqtrace} causes \MF\ to tell you what values are defined by your equations.
\¬\&{titletrace} causes \MF\ to print title statements when they are encountered.
\¬\&{calltrace} causes \MF\ to print the name of a subroutine and its parameter
values, whenever a subroutine is called, and also to print the name of a
subroutine whenever the call is completed.
\¬\&{drawtrace} causes \MF\ to print out numeric specifications of the paths
in \&{draw} or \&{ddraw} commands.
\¬\&{plottrace} causes \MF\ to print lots of detailed information: ``$|w|$''
when generating a new pen of size $w$; ``$(x,y)$'' when plotting raster point
$(x,y)$; ``$(x↓1:x↓2,y)$'' when plotting a horizontal sequence of raster points
from $(x↓1,y)$ to $(x↓2,y)$; ``$(x,y↓1:y↓2)$'' when plotting a vertical sequence
of raster points from $(x,y↓1)$ to $(x,y↓2)$.
\¬\&{modtrace} causes \MF\ to tell you whenever it changes the ``velocities''
$r$ or $s$ when computing cubic curves.
\¬\&{pause} causes \MF\ to show each line of a text file that is being
input, just before that line is scanned. This gives you a chance to edit the
line before hitting \hbox{$\langle$carriage-return$\rangle$},
after which \MF\ will scan the edited line.
If you want to get out of this mode, insert ``{\bf no pause};'' on the line
as you are editing it.
\¬\&{drawdisplay} causes \MF\ to display the raster after completing each \&{draw}
or \&{ddraw} command.\xskip(The present implementation allows this only
when you are running \MF\ from a Datadisc terminal.)
\¬\&{chardisplay} causes \MF\ to display the raster after completing each
section.\xskip(The present implementation allows this only
when you are running \MF\ from a Datadisc terminal.)
\¬\&{pagewarning} causes \MF\ to give a warning message whenever a file page
ends inside a subroutine definition or a section containing a title statement.
\¬\&{penreset} causes \MF\ to undefine the current pen whenever a subroutine
call begins.
\¬\&{proofmode} causes \MF\ to output a file of proofsheets containing the
raster images of each character for which proofmode was in effect at the end
of the section. These proof figures contain point labels for all points that
lie in the ``active'' rectangle, i.e., in the smallest rectangle containing
all pixels affected by the \&{draw} and \&{ddraw} commands for the current
character, provided that the points became known when \&{proofmode} was on.
Thus you can suppress all the points and labels if you turn off \&{proofmode}
until just before finishing the section.\xskip(A point becomes known when
both its $x$- and $y$-coordinates are known; if \&{proofmode} is on at that
moment, the point's location $(x,y)$ is recorded for proofing, after modifying
$(x,y)$ by the transformation parameters \&{trxx} $\ldots$ \&{incy} currently
in force and rounding to the nearest integer.)
\¬\&{fntmode} causes \MF\ to output a file of font images in the format required
by the XGP hardware and software.
\¬\&{crsmode} causes \MF\ to output a file of font images in the format required
by the Alphatype CRS hardware and software. It is illegal to use both \&{fntmode}
and \&{crsmode} in the same program; and it is also ridiculous to do so, since
the CRS has more than 26 times the resolution of the XGP.
\¬\&{chrmode} causes \MF\ to output a text
file of font images in the form of asterisks,
dots, and spaces.\xskip(Such files can be edited with the system text editor,
and there are auxiliary programs to convert font files into and out of this
text format.)
\¬\&{tfxmode} causes \MF\ to output a file of information that \TEX\ needs
for typesetting whenever it uses a font.
\yyskip
\textindent{$\bullet$}\&{varchar} \<expression list\>\hskip 2em Specifies a built-up
character.
\yskip
\textindent{$\bullet$}\&{charlist} \<expression list\>\hskip 2em Specifies a series
of characters.
\yskip
\textindent{$\bullet$}\&{texinfo} \<expression list\>\hskip 2em Specifies \TEX\
font parameters.
\⊗{\&{lig} \<lig instruction list\>} Specifies ligature/kerning information.
These four kinds of
statements are relevant for \&{tfxmode} only, since they provide
detailed information to \TEX. See Appendix F for a detailed explanation.
\⊗{\&{invisible} \<expression$↓1$\>, \<expression$↓2$\>} Preempts a label position.
(Ignored except in \&{proofmode}.)\xskip The command ``\&{invisible} $x,y$''
makes \MF\ think that a point with coordinates $(x,y)$ is going to be labeled,
while in fact it may not be. The purpose is to cause \MF\ to choose a nicer place
for other point labels, since they will now avoid the vicinity of $(x,y)$, thereby
sprucing up proof mode output in certain cases. For
example, \fig 2-3 of this manual was produced using ``\&{invisible} $x↓1,y↓1+1$;
\&{invisible} $x↓2,y↓2+1$;'' this kept the labels 1 and 2 from appearing above
points 1 and 2, where they would have interfered with the illustration. In general,
\MF\ places labels on points by using a fairly simple-minded scheme: From top
to bottom and right to left, the label is put either above the point, or to the
left, or to the right, or below, or off in the right margin, whichever of these
possibilities is first found to be feasible (with respect to the set of
all points to be labeled, all invisible points, and all labels placed so far).
Note that the label positions do not depend on the raster image, only on the
locations of the visible and invisible points.
\yyskip
\tenpoint That completes the list of \MF\ statements. You might wonder why
\&{input} was not in this list, since \&{input} was used several times in the
example of Chapter 4. The reason is that \&{input} is not officially part of a
\<statement\>; it has the effect of redirecting \MF's eyes to a different file,
even in the middle of some other statement. Chapter 4 used the construction
$$\hbox{\&{input} \<file name\>};$$
but this semicolon was unnecessary---\MF\ just executed a null statement after
the input was complete. A \<file name\>\ in the current implement of \MF\ is
any sequence of letters, digits, periods, and/or brackets, so a semicolon is
one way to terminate a file name specification. Another way is to type a
space or a \hbox{$\langle$carriage-return$\rangle$}.
So that's how \MF\ gets input; how does it decide where to put the output?
Answer: It chooses an output file name as explained below, and uses the
respective extensions {\tt.FNT}, {\tt.ANT}, {\tt.XGP}, {\tt.CHR}, {\tt.TFX}
for output produced by \&{fntmode}, \&{crsmode}, \&{proofmode}, \&{chrmode},
\&{tfxmode}. The output file name is the name of the first file you \&{input},
unless \MF\ has to output something before there has been any input from a file.
In the latter case, the output file name is ``{\tt mfput}''.
\chapterbegin 10. {Recovery from errors}
\def\⊃{\penalty1000\noindent}
OK, everything you need to know about \MF\ has been explained---unless you
happen to be fallible.
If you don't plan to make any errors, don't bother to read this chapter. Otherwise
you might find it helpful to make use of some of the ways \MF\ tries to pinpoint
bugs in your routines.
In the trial runs you did when reading Chapter 4, you learned the general form
of error messages, and you also learned the various ways you can respond to
\MF's complaints.
With practice, you will be able to correct most errors ``on line,''
as soon as \MF\ has detected them, by inserting and deleting a few things.
On the other hand, some errors are more devastating than others; one error
might cause some other perfectly valid construction
to be loused up. Furthermore, \MF\ doesn't always diagnose your errors correctly,
since the number of ways to misunderstand the rules is vast, and since \MF\
is a rather simple-minded computer program that doesn't readily comprehend
what you have in mind. In fact, there will be times when you
and \MF\ disagree about something that you feel makes perfectly good sense.
This chapter tries to help avoid a breakdown in communication by presenting
\MF's viewpoint. Though it may seem like madness, there's method in 't.
By looking at the input context that follows an error message, you can often
tell what \MF\ would read next if you were to proceed by hitting
\<carriage-return\>. For example, here is a slightly more complex error message
than we encountered in Chapter 4, since it involves a subroutine call:
$$\vbox{\halign{#\hfill\cr
{\≡! Extra code at end of command will be flushed.≡\}\cr
{\≡<subroutine> dot: x1 = y1 = a; cpen w3≡\}\cr
{\≡≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡
draw 1.≡\}\cr
{\≡p.3,l.9 call dot;≡\}\cr
{\≡≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ ≡ new a;≡\}\cr
{\≡↑≡\}\cr}}$$
In this case the error has occurred in the middle of subroutine \|{dot}, where
a semicolon was forgotten after the pen name \&{cpen}. The next tokens that \MF\
will read are ``\&{draw}'' and ``1'' and then the period ending the subroutine
call, after which \MF\ will read ``\&{new} $a$;'' and proceed to line 10 of page 3
of the current input file. Each pair of lines between the ``{\tt!}'' line and the
``{\≡↑≡\}'' line of an error message shows where \MF\ is currently reading at some
level of input; in this example there are two levels, one in the subroutine
and one outside in page 3 of the file.
The best way to proceed after this particular
error is to type ``{\tt i}'' (for insertion), then (after getting prompted by
``{\tt*}'') to type ``{\tt ; w3}''. This inserts the missing semicolon and
reinserts the $w↓3$ specification that \MF\ is flushing away, so that the program
will proceed as if no error had occurred. In general, it is usually wise to
recover from errors that say ``{\tt command flushed}'' by inserting a semicolon
and as many tokens as needed to provide the desired next statement, after
deleting any tokens you don't wish \MF\ to read.
You can get more information about what \MF\ thinks it is doing by enabling
the various kinds of tracing mentioned in Chapter 9 (\&{calltrace},
\&{drawtrace}, \&{eqtrace}, etc.).
\yskip\ninepoint
Here is a complete list of the messages you might get from \MF, presented
in alphabetic order for reference purposes.
Each message is followed by a brief explanation of the
problem, from \MF's viewpoint, and of what will happen if you proceed by
hitting \<carriage-return\>. This should help you to decide whether or not
to take any remedial action.\xskip
(See also Appendix I for references to these error messages in other
parts of the manual.)
\yskip\noindent{\≡! Bad path, command flushed.≡\}
\⊃ The \<path\>\ in the current \&{draw} or \&{ddraw} command does not
follow the syntactic rules stated in Chapter 9. Proceed, and \MF\ will ignore
all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Boundary too long.≡\}
\⊃ The current character was too complex to be drawn by the Alphatype CRS
hardware. Perhaps it would have been okay if you had chopped it into two
parts using \&{crsbreak}. Proceed; the character will not appear in the font output.
\yskip\noindent{\≡! Character '≡\}\<octal code\>{\≡≡ goes over the top (≡\}\!
\<constant\>{\tt\ > }\<constant\>{\tt).}
\⊃ You didn't specify a large enough \&{maxht}. Proceed, and the top rows of
the current character will be erased.
\yskip\noindent{\≡! Character too tall.≡\}
\⊃The current character covers more than 1023 consecutive rows of the raster,
so it exceeds the hardware capacity of the Alphatype CRS. You need to
break it into two pieces using \&{crsbreak}. Proceed, and a partly erased
character will be output.
\yskip\noindent{\≡! Comma substituted here.≡\}
\⊃ A missing ``,'' has been substituted for the most recently scanned token.
Proceed, after possibly deleting and/or inserting some tokens to make the
remaining expression read as you intended it to.
\yskip\noindent{\≡! Curve out of range.≡\}
\⊃ The current \&{draw} or \&{ddraw} command has requested \MF\ to plot a point
whose $x$-coordinate or $y$-coordinate is too large or too small. Proceed; the
remainder of the current drawing will be omitted.\xskip(It is possible to
increase \MF's drawing range by recompiling the system with different
values of its internal parameters called {\tt xrastmin}, {\tt xrastmax},
{\tt yrastmin}, {\tt yrastmax}.)
\yskip\noindent{\≡! Curve too wild.≡\}
\⊃ The current curve $\biglp x(t),y(t)\bigrp$
being drawn undergoes extremely fast changes for small increments in $t$; are you
trying to break \MF's plotting routine? Proceed, and the remainder of the
current drawing will be omitted.
\yskip\noindent{\≡! Division by 0.≡\}
\⊃ The expression \MF\ is currently evaluating specifies a division by zero.
Proceed, and the division will be bypassed.
\yskip\noindent{\≡! Duplicate charcode: '≡\}\<octal code\>{\tt.}
\⊃ Two routines have specified the same character code. Proceed, and the
previous character will be overlaid by the present one.
\yskip\noindent{\≡! Duplicate ligature/charlist entry, command flushed.≡\}
\⊃ It is illegal to specify two ligature labels for the same character code, or
to include a character in a \&{charlist} when there is a ligature label for it.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Empty pen specification.≡\}
\⊃ The \&{spen} or \&{epen} you have specified contains no points.
Proceed, and \MF\ will substitute a one-point pen.
\yskip\noindent{\≡! epenxfactor must be positive (1.0 assumed).≡\}
\⊃ The value of \&{epenxfactor} cannot be zero or negative. Proceed, and \MF\
will reset it to 1.0 while making the current \&{epen}.
\yskip\noindent{\≡! epenyfactor must be positive (1.0 assumed).≡\}
\⊃ The value of \&{epenyfactor} cannot be zero or negative. Proceed, and \MF\
will reset it to 1.0 while making the current \&{epen}.
\yskip\noindent{\≡! Extra code at end of command will be flushed.≡\}
\⊃ \MF\ has read and interpreted a \<statement\>, so it expected to find a
semicolon or period as the next token. This expectation was not realized.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! hpen height too small, set to 1.≡\}
\⊃ You shouldn't specify a setting of \&{hpenht} that is less than 0.5.
Proceed, and its value will be set to 1.
\yskip\noindent{\≡! Illegal pen size (≡\}\<constant\>{\≡).≡\}
\⊃ The pen size you have specified is either too large or too small. Proceed,
and \MF\ will use size 1 instead.
\yskip\noindent{\≡! Image lost since charcode not specified.≡\}
\⊃ Your program drew something, but no information was output for that character
since you failed to specify any \&{charcode} for it.
Proceed.
\yskip\noindent{\≡! Improper call, command flushed.≡\}
\⊃ There are extraneous tokens following the current \&{call} statement
(e.g., you may be supplying too many parameters). Proceed; the \&{call}
statement and all tokens up to the next semicolon or period will be ignored.
\yskip\noindent{\≡! Improper charlist entry, command flushed.≡\}
\⊃ Your \&{charlist} doesn't follow the rules stated in Appendix F.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Improper index argument, command flushed.≡\}
\⊃ You have just tried to \&{call} a subroutine having an index argument,
but the parameter you are supplying isn't an \<index\>. Proceed; the \&{call}
statement and all tokens up to the next semicolon or period will be ignored.
\yskip\noindent{\≡! Improper index specification.≡\}
\⊃ An \<index\>\ was supposed to have been here (either a digit string or
the name of an index argument in a subroutine), for example after the
word \&{top}. Proceed, and \MF\ will act as if the index were ``0''.
\yskip\noindent{\≡! Improper ligature/kern entry, command flushed.≡\}
\⊃ The current \<lig instruction\>\ doesn't follow the rules stated in Appendix F.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Improper name.≡\}
\⊃ This token can't be made \&{new} (e.g., ``\&{new} 5'').
Proceed, and it will be ignored.
\yskip\noindent{\≡! Improper pen specs, command flushed.≡\}
\⊃ You have not followed the rules of an \&{spen} or \&{epen} specification.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Incompatible resolution.≡\}
\⊃ You can't simultaneously select output in {\tt fntmode} and {\tt crsmode}.
\yskip\noindent{\≡! Inconsistent equation.≡\}
\⊃ The equation just given does not jibe with information \MF\ already knows
from previous equations.\xskip(If you can't understand why, try running your
program again with \&{eqtrace} on.)\xskip Proceed, and the inconsistent
equation will be ignored.
\yskip\noindent{\≡! Indeterminate relation.≡\}
\⊃ \MF\ has just scanned ``\&{if} \<relation\>:'' but it was impossible to decide
whether the relation is true or false based on the equations given so far.
To recover, insert and/or delete tokens so that the next thing \MF\ reads is
a correct conditional statement (you must reinsert the ``\&{if}'' as well as
a relation).
\yskip\noindent{\≡! Input page ended while scanning def of ≡\}\<subroutine name\>.
\⊃ The end of a file page occurred between the beginning of a subroutine definition
and the period ending that subroutine.\xskip(It is possible
to suppress this message by putting \MF\ in {\bf no pagewarning} mode.)
\yskip\noindent{\≡! Input page ended while scanning "≡\}\<title\>{\≡".≡\}
\⊃ The end of a file page occurred between a quoted title statement and the
period ending that routine; this may indicate an \&{if} not closed by \&{fi},
or some other anomaly, or it might not be an error at all.\xskip(It is possible
to suppress this message by putting \MF\ in {\bf no pagewarning} mode.)
\yskip\noindent{\≡! Ligature/kern table didn't end.≡\}
\⊃ The final entry of your final \<lig instruction list\>\ was a continuation
entry. Proceed, but don't be surprised if \TEX\ blows up trying to use
the font information produced on this run.
\yskip\noindent{\≡! Lookup failed on file ≡\}\<filename\>.
\⊃ \MF\ can't find the file you indicated. Type ``{\tt i}'' and insert the correct
file name (followed by a \hbox{$\langle$carriage-return$\rangle$}). But be careful: You get only one more
chance to get the file name right, otherwise \MF\ will decide not to input
{\sl any} file just now.
\yskip\noindent{\≡! METAFONT capacity exceeded, sorry [≡\}\<size\>=\<number\>{\tt].}
\⊃ This is a bad one. Some how you have stretched \MF\ beyond its finite limits.
The thing that overflowed is indicated in brackets, together with its numerical
value in the \MF\ implementation you are using. The following table shows the
internal sizes that might have been exceeded:
$$\vbox{\halign{\tt#\hfill⊗\quad#\hfill\cr
epensize⊗number of $(l,r)$ pairs in an \&{epen} specification;\cr
maxpoints⊗number of points in a curve to be drawn;\cr
memsize⊗memory above {\tt vmemsize} used to store tokens;\cr
names⊗number of bits used to represent subscripts;\cr
namesize⊗memory used to store identifiers;\cr
pmemsize⊗memory used to store information about pens and erasers;\cr
proofmemsize⊗number of visible and invisible points for proof sheets;\cr
stacksize⊗number of simultaneous input sources;\cr
vmemsize⊗memory used to store variable values and many other things;\cr
xpenmax⊗largest $x$-coordinate of a pen or eraser;\cr
xpenmin⊗smallest $x$-coordinate of a pen or eraser;\cr
xrastmax⊗maximum $x$-coordinate allowed when plotting;\cr
ypenmax⊗largest $y$-coordinate of a pen or eraser;\cr
ypenmin⊗smallest $y$-coordinate of a pen or eraser;\cr
yrastmax⊗maximum $y$-coordinate allowed when plotting.\cr}}$$
If your job is error-free, the remedy is to recompile the \MF\ system,
increasing what overflowed. However, you may be able to think of a way to
change your program so that it does not push \MF\ to extremes.
\yskip\noindent{\≡! Missing "(", command flushed.≡\}
\⊃ You have just tried to \&{call} a subroutine without supplying enough
parameters. Proceed; the \&{call} statement and all tokens up to the next
semicolon or period will be ignored.
\yskip\noindent{\≡! Missing ",", command flushed.≡\}
\⊃ The first \<path\>\ in the current \&{ddraw} command, or the first
coordinate in the current \&{invisible} command, was not followed by a
comma. Proceed, and \MF\ will ignore all tokens up to the next semicolon or
period.
\yskip\noindent{\≡! Missing ":".≡\}
\⊃ \MF\ has just scanned ``\&{if} \<relation\>'' and the next token should
have been a colon.
To recover, insert and/or delete tokens so that the next thing \MF\ reads is
a correct conditional statement (you must reinsert the ``\&{if}'' as well as
a relation and a colon).
\yskip\noindent{\≡! Missing = sign, command flushed.≡\}
\⊃ A \MF\ statement began with an expression, but the next token was neither ``=''
nor ``\&{draw}'' nor ``\&{ddraw}''. The value of this expression, in terms
of independent variables, has been printed out on the line just preceding this
error message.\xskip(See Chapter 4 for several examples.)\xskip
Proceed, and \MF\ will ignore the expression and all tokens up to the next
semicolon or period.
\yskip\noindent{\≡! Missing colon inserted.≡\}
\⊃ There should have been a ``:'' after the word \&{else}; \MF\ has inserted one.
\yskip\noindent{\≡! Missing punctuation, command flushed.≡\}
\⊃ You are trying to \&{call} a subroutine, but you didn't supply a comma
or a right parenthesis after the current parameter. Proceed; the \&{call}
statement and all tokens up to the next semicolon or period will be ignored.
\yskip\noindent{\≡! Missing relation.≡\}
\⊃ \MF\ has just scanned ``\&{if} \<expression\>'' and the next token should
have been one of the six relation symbols ($<$, $>$, $=$, $≤$, $≥$, $≠$).
To recover, insert and/or delete tokens so that the next thing \MF\ reads is
a correct conditional statement (you must reinsert the ``\&{if}'' and
fix the relation).
\yskip\noindent{\≡! Negative chardw, replaced by 0.≡\}
\⊃ The value of \&{chardw} must not be negative. Proceed; it has become 0.
\yskip\noindent{\≡! No parameter name.≡\}
\⊃ The word ``\&{var}'' or ``\&{index}'' should be followed by an identifier that
will be the name of the argument being specified. Proceed, and \MF\ will bypass
the most recently scanned token and argument;
you may want to insert another argument with the correct name.
\yskip\noindent{\≡! No pen defined.≡\}
\⊃ You are trying to \&{draw} or \&{ddraw}, but the current pen type has not
been defined. Proceed, and \MF\ will use \&{cpen}.
\yskip\noindent{\≡! No subroutine name, command flushed.≡\}
\⊃ The word ``\&{subroutine}'' should be followed by an identifer that will
be the name of the subroutine being defined. Proceed, and \MF\ will ignore
all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Paths don't match up, command flushed.≡\}
\⊃ The two paths in the current \&{ddraw} command have unequal numbers of points.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Pen size too small (≡\}\<constant\>{\≡), replaced by 1.0.≡\}
\⊃ The pen size enclosed in ``$|$'' signs (within a variable-size \&{draw}
command) should not be less than 1.0. Proceed, and \MF\ will act as if it
were 1.0.
\yskip\noindent{\≡! Program ended while defining ≡\}\<subroutine name\>{\tt.}
\⊃ Premature occurrence of the word {\tt end} leads to a premature end.
\yskip\noindent{\≡! Rectangle too wide.≡\}
\⊃ You have specified an \&{lpen} or \&{rpen} with too much width for \MF's
capacity. Proceed, and \MF\ will cut the width to the maximum it can handle.
\yskip\noindent{\≡! Recursive call not allowed, command flushed.≡\}
\⊃ You have just tried to \&{call} a subroutine having a parameter whose
value is already defined from another \&{call} not yet complete.\xskip(Recursion
is allowed only with parameterless subroutines.)\xskip Proceed; the \&{call}
statement and all tokens up to the next semicolon or period will be ignored.
\yskip\noindent{\≡! Redundant equation.≡\}
\⊃ The equation just given does not present any information that \MF\ didn't
already know from previous equations.\xskip(If you can't understand why,
try running your program again with \&{eqtrace} on.)\xskip Proceed; no harm
has been done.
\yskip\noindent{\≡! Right bracket substituted here.≡\}
\⊃ A missing ``]'' has been substituted for the most recently scanned token.
Proceed, after possibly deleting and/or inserting some tokens to make the
remaining expression read as you intended it to.
\yskip\noindent{\≡! Right parenthesis substituted here.≡\}
\⊃ A missing ``)'' has been substituted for the most recently scanned
token. Proceed, after possibly deleting and/or inserting some tokens to make the
remaining expression read as you intended it to.
\yskip\noindent{\≡! Rounding of ≡\}\<char dimension\>{\≡≡ necessary, ≡\}\!
\<constant\>{\tt\ → }\<constant\>{\tt.}
\⊃ The characters in the present font have too many distinct dimensions of the
specified type for \TEX\ to handle.\xskip(For example, some versions of \TEX\
will allow at most 16 different values of \&{charht} per font.)\xskip The
specified approximation has been used; if you want uniformity between different
machines, you should redefine the dimensions in accordance with \TEX's limits.
\yskip\noindent{\≡! Routine ended in skipped conditional text.≡\}
\⊃ Something is awry, since a period or \&{end} has occurred in the midst
of part of your program that is being skipped over (because it's in the
unselected part of a conditional). Proceed if you dare.
\yskip\noindent{\tt Sharp turn suppressed between points }\<point names\>\!
{\tt\ (}\<velocity\>{\tt)}
\⊃ (This is not really an error message, it's a warning that you get when
\&{modtrace} is in effect.)\xskip The curve \MF\ is about to draw would have
had a sharp turn at one of the stated points (the first point if the ``$r$''
velocity is given, the second if the ``$s$'' velocity is given), because of the
angles the curve is supposed to take between those two points. The
velocity derived by \MF's normal rules
is below \&{minvr} or \&{minvs}, so \MF\ is suppressing the sharp turn by
raising the velocity to the corresponding minimum value.\xskip(Cf.\ the latter
part of Chapter
2 for further discussion.)\xskip This usually is a
symptom of some problem in your program, although it may be perfectly all right.
\yskip\noindent{\≡! Should be "(" or "," or ":" here.≡\}
\⊃ One of these three tokens is needed, since an argument list is being
scanned; you should insert and/or delete tokens so that
\MF\ sees the correct one, to get it back into synch.
\yskip\noindent{\≡! Should say var or index here.≡\}
\⊃ The word ``\&{var}'' or ``\&{index}'' should have appeared at this point, to
define the next subroutine argument. Proceed, and the most recently scanned
token will be ignored.
\yskip\noindent{\≡! String must end on the line where it begins.≡\}
\⊃ A quoted title cannot contain a \hbox{$\langle$carriage-return$\rangle$}; the title you supplied
therefore seems to have ended without its closing ``{\tt "}'' mark. Proceed,
and \MF\ will act as though the ``{\tt "}'' had been present here.
\yskip\noindent{\≡! Subroutine definition should follow ".".≡\}
\⊃ A subroutine definition should not begin between a title statement and the
period ending the corresponding routine. Proceed; \MF\ will define the subroutine
and resume the routine, forgetting its title.
\yskip\noindent{\≡! Subroutines can't be defined inside subroutines.≡\}
\⊃ Each subroutine should be a section unto itself. Proceed, and the word
``\&{subroutine}'' will be ignored; however, some other errors will probably show up
unless you insert the text ``{\tt . subroutine}'' now to recover from this error.
\yskip\noindent{\≡! This can't happen.≡\}
\⊃ An internal consistency check has failed, causing \MF\ to be
totally confused. Either you did something the author was unable to foresee,
or somebody has been tampering with the \MF\ system programs.
\yskip\noindent{\≡! Titles are ignored inside subroutines.≡\}
\⊃ You aren't supposed to have title statements in subroutines. Proceed, and
this here one will be ignored.
\yskip\noindent{\≡! Too many different chardw values.≡\}
\⊃{\≡! Too many different charic/varchar values.≡\}
\⊃ The \TEX\ character information for the current font is too complex; \TEX\
puts limits on the maximum number of distinct values of \&{chardw} and
\&{charic}/\&{varchar} in any one font.\xskip(See Appendix F.)
\yskip\noindent{\≡! Too many ligatures, command flushed.≡\}
\⊃ Your program is supplying more ligature/kern entries than \TEX\ can tolerate
in one font.\xskip(Some implementations of \TEX\ have restricted capacity,
but the present Stanford version allows 512, which should be plenty.)\xskip
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Too much texinfo, command flushed.≡\}
\⊃ Your program is supplying more information parameters than \TEX\ can understand.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! Undefined pen.≡\}
\⊃ You are using a \<direction\>\ operation like \&{top}, but the current pen type has not
been defined. Proceed, and \MF\ will ignore the \<direction\>\ operation.
\yskip\noindent{\≡! Undefined pen size.≡\}
\⊃ The current pen size being supplied before the word \&{draw} or \&{ddraw}
does not have a known value; its value in terms of independent variables
has been printed out on the line just preceding this error message. Proceed,
and the current pen size will retain its former value.
\yskip\noindent{\≡! Undefined ≡\}\<something\>{\≡, replaced by ≡\}\<constant\>{\tt.}
\⊃ The line before this error message shows the current value of the \<something\>\
that should have a definite value at this point, expressed as a linear combination
of independent variables. The \<something\>\ might be any of the following:
$$\vbox{\halign{\tt#\hfill\quad⊗#\hfill\cr
character code⊗first \<expression\>\ in a ligature/kern instruction;\cr
cosine⊗operand of \&{cosd};\cr
divisor⊗$β$ in a term of the form $α/β$;\cr
expression⊗entire \<expression\>\ whose value is needed;\cr
factor⊗one factor of a product, when neither are defined;\cr
goodee⊗operand of \&{good}$↓i$;\cr
interval fraction⊗$α$ in a term of the form $α[β,\gamma]$;\cr
root⊗operand of \&{sqrt};\cr
roundee⊗operand of \&{round};\cr
sine⊗operand of \&{sind}.\cr}}$$
Proceed, and the computation will continue as though the \<something\>\ had the
stated \<constant\>\ value.
\yskip\noindent{\≡! Undefined subroutine, command flushed.≡\}
\⊃ You have just tried to \&{call} a subroutine that isn't currently
defined. Proceed; the \&{call} statement and all tokens up to the next
semicolon or period will be ignored.
\yskip\noindent{\≡! Undefined size w≡\}\<digit string\>{\tt.}
\⊃ Your program is using an operation like ``\&{top}$↓6$'' when the corresponding
$w$-variable (e.g., $w↓6$) does not have a known value. Proceed, and the value
will be assumed zero.
\yskip\noindent{\≡! Unknown control code, command flushed.≡\}
\⊃ The word ``{\bf no}'' must be followed by one of \MF's control codes.
Proceed, and the tokens up to the next semicolon or period will be ignored.
\yskip\noindent{\≡! Variable ≡\}\<variable name\>{\≡≡ never defined.≡\}
\⊃ The stated variable is about to become undefined (e.g., it is being made
\&{new}, or it is an $x$-variable and a routine or subroutine is ending), but
it has never gotten a fully known value. Thus, other variables might be
depending on this one, because of equations that gave incomplete information.
Proceed, and \MF\ will try to keep going.\xskip (If this variable is
independent, it will essentially be replaced by 1.0 in the equations for
all variables that depend on it.)
\yskip\noindent{\≡! Variable x≡\}\<point number\>{\≡≡ is undefined, 0.0 assumed.≡\}
\⊃ \MF\ is about to carry out a \&{draw} or \&{ddraw} command, but the
$x$-coordinate of this particular point does not have a known value.\xskip(The
point number may be preceded by lower case letters if the point is defined
within a subroutine, as explained in Chapter\penalty999\ 8.)\xskip Proceed, and the
drawing will take place using zero as the $x$ coordinate.
\yskip\noindent{\≡! Variable y≡\}\<point number\>{\≡≡ is undefined, 0.0 assumed.≡\}
\⊃ \MF\ is about to carry out a \&{draw} or \&{ddraw} command, but the
$y$-coordinate of this particular point does not have a known value.\xskip(The
point number may be preceded by lower case letters if the point is defined
within a subroutine, as explained in Chapter\penalty999\ 8.)\xskip Proceed, and the
drawing will take place using zero as the $y$ coordinate.
\yskip\noindent{\tt Velocity reduced between points }\<point name\>{\tt\
and }\<point name\>{\tt\ (}\<velocity\>{\tt)}
\⊃ (This is not really an error message, it's a warning that you get when
\&{modtrace} is in effect.)\xskip The curve \MF\ is about to draw would have
had unusual behavior near
one of the stated points (the first point if the ``$r$''
velocity is given, the second if the ``$s$'' velocity is given), because of the
angles the curve is supposed to take between those two points. The
velocity derived by \MF's normal rules
is above \&{maxvr} or \&{maxvs}, so \MF\ is suppressing the wildness of the curve
by lowering the velocity to the corresponding maximum value.\xskip(Cf.\ the latter
part of Chapter
2 for further discussion.)\xskip This usually is a
symptom of some problem in your program, although it may be perfectly all right.
\yskip\noindent{\≡! vpen width too small, set to 1.≡\}
\⊃ You shouldn't specify a setting of \&{vpenwd} that is less than 0.5.
Proceed, and its value will be set to 1.
\yskip\noindent{\≡! w-variable not followed by proper subscript.≡\}
\⊃ An identifier can't start with the letter {\tt w}; thus you can't use a
variable named {\tt width} except in a subroutine having an index parameter
named {\tt idth}. Proceed, and \MF\ will act as though the offending $w$-variable
were zero.
\yskip\noindent{\≡! Whoops, you need a Datadisc for display modes.≡\}
\⊃ The \&{drawdisplay} and \&{chardisplay} control bits of \MF\ can be turned on
only if you are using it from a Datadisc terminal. Proceed, and these bits
will be turned off.
\yskip\noindent{\≡! x-variable not followed by proper subscript.≡\}
\⊃ An identifier can't start with the letter {\tt x}; thus you can't use a
variable named {\tt xheight} except in a subroutine having an index parameter
named {\tt height}. Proceed, and \MF\ will act as though the offending $x$-variable
were zero.
\yskip\noindent{\≡! y-variable not followed by proper subscript.≡\}
\⊃ An identifier can't start with the letter {\tt y}; thus you can't use a
variable named {\tt year} except in a subroutine having an index parameter
named {\tt ear}. Proceed, and \MF\ will act as though the offending $y$-variable
were zero.
\yskip\noindent{\≡! You can't begin a "primary" like that.≡\}
\⊃ At this point in your program, \MF\ is expecting to see a \<primary\>, but
the token it has just scanned cannot be used at the beginning of a \<primary\>\
expression.\xskip(Perhaps it is a reserved word that you intended to use as
the name of a variable.)\xskip Proceed, and \MF\ will pretend that the
token it has just scanned was ``0''.
\yskip\noindent{\≡! You can't begin a statement like that, command flushed.≡\}
\⊃ The token \MF\ has just read was supposed to be the first one of a \<statement\>,
but no \<statement\>\ can possibly start with this particular token.
Proceed, and \MF\ will ignore all tokens up to the next semicolon or period.
\yskip\noindent{\≡! You can't start an expression like that.≡\}
\⊃ At this point in your program, \MF\ is expecting to see an \<expression\>, but
the token it has just scanned cannot be used at the beginning of an
\<expression\>.\xskip(Perhaps it is a reserved word that you intended to use as
the name of a variable.)\xskip Proceed, and \MF\ will pretend that the
token it has just scanned was a \<term\>\ of value zero.
\yskip\noindent{\≡! You can't vary the pen size with ≡\}\<pen type\>{\tt.}
\⊃ A \&{draw} command with varying sizes cannot be performed with a \&{cpen},
\&{spen}, or \&{epen}. Proceed; the current drawing will be omitted.
\tenpoint
\vfill
\specialappbegin A. {Answers to all the exercises}
\ninepoint
\def\ansno #1: {\yskip\noindent\hbox to 21.9pt{\hskip0pt plus 1000000pt
minus 1000000pt \bf#1: }}
\ansno 1.1: Replace the first line by ``$x↓1=x↓4$; $x↓2=x↓5$; $x↓3=x↓6$;
$x↓2-x↓1=x↓3-x↓2$; $\&{lft}↓1x↓1=0$; $\&{rt}↓1x↓3=2d-2$;''.\xskip (Adjacent
characters will be separated by exactly one white pixel, not two,
if the width of the character is $2d$ pixels, because a character of width
$2d$ extends from column 0 to column $2d-1$, inclusive.)
\ansno 2.1: A straight line from point 1 to point 2, and another
from point 2 to point 3.
\ansno 2.2: The same ``curve'' as in exercise 2.1(!).
\ansno 3.1: \&{epen} $(-7,-1)(-7,-1)(-7,-1).(-7,-1)(-7,-1)$;
if the height
were 4 instead of 5, the final ``$(-7,-1)$'' would be omitted and ``\&{epenycorr}
0.5'' would be used to center the pen vertically.
\ansno 3.2: Program 1 yields an ellipse of width 75 and height 25, centered
at the origin $\biglp$i.e., at point (0,0)$\bigrp$.
Program 2 draws a shape of the same width
and height---but it is composed of two semicircles of diameter 25 at the
left and right, connected in the middle by a $25\times50$ rectangle.
\ansno 4.1: {\≡w0 draw 4{1,0}..1{0,1}; draw 3{0,1}..2{1,0}.≡\}
\ansno 4.2: Yes.
\ansno 5.1: (a) $x↓1$.\xskip(b) If $x↓1$ is on one side of $x↓2$, this point is
on the opposite side, at a distance from $x↓2$ that is half the distance from
$x↓2$ to $x↓1$.\xskip(Imagine walking from $x↓1$ toward $x↓2$ at a constant
speed that gets you there after one day; keep walking for a total of 3/2
days.)\xskip (c) $1/2[x↓1,x↓2]$. The formula $(x↓1+x↓2)/2$ is one symbol
shorter, but it is less descriptive once the bracket notation is understood.
\ansno 5.2: (a) Yes.\xskip(b) No.\xskip(c) No (that one means $\sqrt{x↓1x↓2}\,$).
\ansno 6.1: The curve would be filled in between points 2 and 8, obliterating
point 1, since 2 and 8 are corresponding points.
\ansno 6.2: At least two ways will work.\xskip(a) By setting ``\&{safetyfactor}
0.22222'' and using ``1 \&{ddraw} $\ldots$'', the value of $m$ is computed
as if the pen size were 9 instead of 1. The safety factor must be reset to 2.\xskip
(b) By using ``\&{epen} $(0,0)$; 9 \&{ddraw} $\ldots$'' you get the effect
of a width-9 \&{cpen} but with an explicitly defined pen that blackens only
one pixel at each point. Similarly an \&{spen} could be used.
\ansno 8.1: \&{subroutine} \|{curve}(\&{var} \|{theta}, \&{var} \|{phi},
\&{index} $i$, \&{index} $j$):
\noindent \&{cpen}; 1 \&{draw} $i\{\&{cosd}\,\|{theta}, \&{sind}\,\|{theta}\}
\to j\{\&{cosd}\,\|{phi}, -\&{sind}\,\|{phi}\}$.
\ansno 8.2: ca1, ca2, cab1, cab2, cabb1, cabb2, cabbb1, cabbb2.\xskip
(The value of xca3 is the same as that of xcab1, but no point is labeled
ca3 since yca3 is never defined.)
\vfill
\specialappbegin E. {Example of a font definition}
The alphabets used to typeset this manual belong to the ``Computer Modern''
family of fonts developed by the author at the same time as \MF\ itself
was taking shape. Further experience will doubtless suggest many improvements,
and in fact the design of Computer Modern is still far from finished.
The purpose of this
appendix is to illustrate what the author has learned so far about the task
of designing a fairly complete alphabet, so that you can get an idea of why
he finds it such a pleasant undertaking.
A complete font design is, of course, a complex system, so there are several levels
at which one might understand it and use it---depending on how much of the
``black box'' is being opened. At the outermost level, all of the details can be
left alone and we simply generate a particular font. For example, there is a file
called ``{\tt cmr10.mf}'', and when \MF\ is applied to that file it will produce
the ``Computer Modern Roman 10 point'' font. Another file ``{\tt cmsss8.mf}''
produces ``Computer Modern Slanted Sans Serif 8 point,'' and so on. But if we actually
look into files like {\tt cmr10.mf} and {\tt cmsss8.mf}, we find that they are
quite short; they merely set up the values of certain parameters and
input the file ``{\tt roman.mf}'', which contains the actual \MF\ programs for
individual leters. Therefore it is easy to make up a customized
font for a particular application, simply by setting up new values of those
parameters and inputting {\tt roman.mf} ourselves.
At a still deeper level, we can also look at the file {\tt roman.mf}, which consists of
128 short programs for the individual character shapes (followed by ligature and
kerning definitions). These short programs are fairly independent, and they
aren't completely inscrutable; it isn't difficult to substitute a new routine or
two for characters that we wish to modify, since the programs make use of some
fairly flexible subroutines that appear in file {\tt cmbase.mf}.
At the deepest level, we could also fiddle with the subroutine definitions in
{\tt cmbase.mf}---and of course
that would essentially amount to the creation of a new
family of fonts.
\yskip
In this appendix we shall study the Computer Modern fonts by working our way in
from the outermost level. File {\tt cmr10.mf} looks like this:
$$\baselineskip15pt\halign{\hskip 3em$ # $\hfill\cr
\hbox{{\tt"}Computer Modern Roman 10 point{\tt"};}\cr
\|{ph}={250\over36};\quad \|{px}={160\over36};\quad \|{pe}={90\over36};\quad
\|{pd}={70\over36};\cr
\|{pb}={20\over36};\quad \|{po}={4\over36};\quad\|{ps}={20\over36};\quad
\|{pa}=.5(\|{ph}-\|{pd});\cr
\|{pw}={9\over36};\quad\|{pwi}={27\over36};\quad\|{pwii}={32\over36};\quad
\|{pwiii}={36\over36};\cr
\|{pwiv}={32\over36};\quad\|{pwv}={38\over36};\quad\|{aspect}=1.0;\cr
\|{pu}={20\over36};\quad\|{lcs}=1.075;\quad\|{ucs}=1.7;\quad\|{sc}=0;\cr
\|{slant}=0;\quad\|{sqrttwo}=\&{sqrt}\,2;\quad\|{fixwidth}=0;\cr
\|{halfd}=0;\quad\|{varg}=0.\cr
\hbox{\&{input} {\tt cmbase};\quad \&{call} \|{fontbegin};}\cr
\hbox{\&{input} {\tt roman};}\cr
\&{end}.\cr}$$
In other words, the file sets up a lot of parameters and then it does
``\&{input} {\tt roman}'' to create the font.
\yyskip
We can obtain a great variety of
related fonts by setting these parameters in different ways, once we know
what they mean; and here's what they mean:
\yyskip\noindent
By convention, all of the parameters whose name begins with ``{\sl p}'' are in
units of printers' points. First come eight parameters covering important
vertical dimensions:
\def\¬{\par\yskip\hangindent 4em$ $}
\¬\|{ph} is the h-height, the distance from the baseline to the top of an ``h''.
\¬\|{px} is the x-height, the distance from the baseline to the top of an ``x''.
\¬\|{pe} is the e-height, the distance from the baseline to the bar of an ``e''.
\¬\|{pd} is the descender depth, the distance from the baseline to the bottom
of a ``p''.
\¬\|{pb} is the border height; characters extend as much as $\|{ph}+\|{pb}$
above the baseline and $\|{pd}+\|{pb}$ below it.
\¬\|{po} is the amount of overshoot for optical adjustments at sharp corners;
e.g., ``A'' is this much taller than ``B''.
\¬\|{ps} is the vertical distance at which serif bracketing is tangent to the stems.
\¬\|{pa} is the axis height, the distance from the baseline to the point where
mathematical symbols like ``+'' and ``='' have vertical symmetry.
\yyskip\noindent
Then there are seven parameters affecting the pen sizes:
\¬\|{pw} is the hairline width, used in the thinnest parts of letters.
\penalty1000
\¬\|{pwi} is the stem width, used for the vertical strokes in an ``h''.
\¬\|{pwii} is the curve width, used in an ``o'' at its widest point.
\¬\|{pwiii} is the dot width, the diameter of the dot on an ``i''.
\¬\|{pwiv} is the upper-case stem width, used for the vertical strokes in an ``H''.
\¬\|{pwv} is the upper-case curve width, used in an ``O'' at its widest point.
\¬\|{aspect} is the ratio of a hairline pen's width to its height.
\yyskip\noindent
Next come four parameters concerning horizontal dimensions:
\¬\|{pu} is the unit width, 1/18 of an em.
\¬\|{lcs} is the amount by which serifs of lower-case letters project from
the stems, in units of \|{pu}.
\¬\|{ucs} is the amount by which serifs of upper-case letters project from
the stems, in units of \|{pu}.
\¬\|{sc} is the serif correction in units of \|{pu}; each letter specifies
multiples of \|{sc} by which its width is to be decreased at the left and the right.
\yyskip\noindent
Finally we have miscellaneous parameters that control special effects:
\¬\|{slant} is the amount of additional increase in $x$ per unit increase in $y$,
used to slant letters either {\sl forwards\/} or {\hskip1pt\:? backwards}.
\¬\|{sqrttwo} is used to control the ellipticity of the bowls of letters, as
explained in Chapter 8.
\¬\|{halfd} is nonzero if certain characters like ``,'' are to descend only half
as far as lower-case letters do.
\¬\|{varg} is nonzero if the simple ``{\:=g}'' shape is to replace the classical
``g''.
\yyskip
File {\tt cms10.mf} (``Computer Modern Slanted 10 point'') is exactly the same as
file {\tt cmr10.mf}, except for its title and the fact that $\|{slant}=0.15$.
Similarly, the settings of parameters in file {\tt cmb10.mf}
(``Computer Modern Bold 10 point'')
are nearly identical to those of {\tt cmr10.mf}, except that the pens
are bigger:
$$\baselineskip15pt\vbox{\halign{$#\hfill$\cr
\|{pw}={15\over36};\quad\|{pwi}={40\over36};\quad\|{pwii}={45\over36};\quad
\|{pwiii}={50\over36};\cr
\|{pwiv}={50\over36};\quad\|{pwv}={50\over36};\cr}}$$
furthermore serifs are shorter ($\|{lcs}=.85$, $\|{ucs}=1.5$).
File {\tt cmr5.mf} generates 5-point type, but it is not simply obtained by
halving the parameters of cmr10. The eight vertical dimensions \|{ph},
\|{px}, $\ldotss$, \|{pa} are exactly half as large as before, but the pen
sizes and the horizontal dimensions get smaller at different rates {\:f so as
to enhance the readability of such tiny letters}. The following settings are used:
$$\baselineskip15pt\vbox{\halign{$#\hfill$⊗\quad$#\hfill$⊗\quad$#\hfill$\cr
\|{pw}={7\over36},⊗\|{pwi}={15\over36},⊗\|{pwii}={18\over36};\cr
\|{pwiii}={20\over36},⊗\|{pwiv}={19\over36},⊗\|{pwv}={20\over36};\cr
\|{pu}={25\over72},⊗\|{lcs}=0.92,⊗\|{ucs}=1.32.\cr}}$$
Two more examples should suffice to illustrate the variation of these
pa\-ram\-eters.
{\:<The bold sans-serif font used in this sentence and in the chapter headings
of this manual is called ``Computer Modern Sans Serif 10 point Bold Extended''
(cmssb).} It uses the same vertical dimensions and miscellaneous settings as
cmr10, and gets its other characteristics from the following parameter values:
$$\baselineskip15pt\vbox{\halign{$#\hfill$\cr
\|{pw}=\|{pwi}=\|{pwii}=\|{pwiii}={37\over36};\cr
\|{pwiv}=\|{pwv}={42\over36};\quad\|{aspect}={37\over23};\cr
\|{pu}={22\over36};\quad\|{lcs}=\|{ucs}=0;\quad\|{sc}={9\over22}.\cr}}$$
{\tt To get the typewriter font "cmtt" used in this sentence, set}
$$\baselineskip15pt\vbox{\halign{$#\hfill$\cr
\|{ph}={210\over36};\quad\|{px}={150\over36};\quad\|{pe}={75\over36};\quad
\|{pd}={80\over36};\cr
\|{pb}={30\over36};\quad\|{po}=0;\quad\|{ps}=0;\quad\|{pa}={85\over36};\cr
\|{pw}=\|{pwi}=\|{pwii}=\|{pwiv}=\|{pwv}={20\over36};\cr
\|{pwiii}={30\over36};\quad\|{aspect}=1.0;\cr
\|{pu}={23\over36};\quad\|{lcs}={8\over23};\quad\|{ucs}={19\over23};\quad\|{sc}=0;\cr
\|{slant}=0;\quad\|{sqrttwo}=\&{sqrt}\,2;\quad\|{fixwidth}=1;\cr
\|{halfd}=1;\quad\|{varg}=0.\cr}}$$
{\:? By making stranger settings of the parameters you can also get strange
fonts like this.}
\yskip
The programs for Computer Modern can be used in several ways. The
general procedure is to run \MF\ and type
$$\hbox{{\tt mode =
}$\langle$mode number$\rangle${\tt; input }$\langle$font name$\rangle$;}$$
the routines will act differently depending on the specified mode. At present
mode 0 generates proof sheets and shows the letters as they are being drawn, with
a resolution of 36 pixels per point; mode 1 generates a font for the XGP with a
resolution of 3.6 pixels per point, displaying the letters on a Datadisc just
after they are drawn; and mode 2 generates a font for the CRS with a resolution of
73.7973 pixels per point, displaying the titles of the letters as they are being
drawn. In mode 0 the letters appear on a background grid as shown in \fig E-1,
so that you can see the settings of the parameters in a convenient way.
\topinsert{\vskip 300pt
\ninepoint\ctrline{\hbox par 335pt{{\bf Fig.\ E--1.}\xskip
Two characters of font cmr10, as they appear when drawn with ``mode 0''.
The horizontal guidelines indicate the h-height, x-height, e-height, and the depth of
descenders in this font. The vertical guidelines are one ``unit'' apart, where
there are 18 such units to an em.}}}
Actually mode 0 is rarely used with an entire font like cmr10, it is
generally used to test out new characters. In that case you can make up a
file called ``{\tt test.mf}'' containing the characters you wish to try, and
simply input the system file ``{\tt proof.mf}'', which has the following form:
$$\baselineskip14pt\halign{\hskip3em$#\hfill$\cr
\|{mode}=0;\quad\&{input }\hbox{\tt cmbase};\cr
\|{ph}={250\over36};\quad\ldotsm\langle\hbox{set up for cmr10}\rangle\ldotsm;
\quad\&{call }\|{fontbegin}.\cr
\&{input }\hbox{\tt test};\cr
\&{new }\|{pw},\ldotsm\langle\hbox{set up for cmb10}\rangle\ldotsm;
\quad\&{call }\|{fontbegin}.\cr
\&{input }\hbox{\tt test};\cr
\&{new }\|{pw},\ldotsm\langle\hbox{set up for cmssb}\rangle\ldotsm;
\quad\&{call }\|{fontbegin}.\cr
\&{input }\hbox{\tt test};\cr
\&{new }\|{ph},\ldotsm\langle\hbox{set up for cmtt}\rangle\ldotsm;
\quad\&{call }\|{fontbegin}.\cr
\&{input }\hbox{\tt test};\cr
\&{new }\|{ph},\ldotsm\langle\hbox{set up for cmsss8}\rangle\ldotsm;
\quad\&{call }\|{fontbegin}.\cr
\&{input }\hbox{\tt test};\cr
\&{end}.\cr}$$
Thus, it runs your test file against five different settings of the parameters.
\yskip\ninepoint
Let's go one level deeper and take a look at the programs for individual
letters; examples appear in Figs.\ E--2 and E--3 later in this
appendix. Such programs are expressed
in terms of variables something like the parameters we have been discussing,
but the variables are slightly different since the
letters are to be drawn on a raster and we need to work in raster units
instead of printers' points. The point-oriented variables \|{ph}, \|{px},
\|{pe}, etc., have corresponding raster-oriented variables, satisfying the
approximate relation
$$\langle\hbox{raster-oriented variable}\rangle\approx\|{pixels}{\cdot}\langle
\hbox{point-oriented variable}\rangle,$$
where \|{pixels} is the number of pixels per point. This relation is only
approximate, not exact, because the raster-oriented variables have been rounded
to values that help to provide satisfactory discretization of the characters.
As explained in Chapter 7, good designs are written with discreteness in
mind, although \MF\ tries to do the right thing automatically when it can.
There are seven raster-oriented variables corresponding to seven of the eight
pixel-oriented vertical dimensions, namely
$$h↔\|{ph},\;m↔\|{px},\;e↔\|{pe},\;d↔\|{pd},\;b↔\|{pb},\;o↔\|{po},\;a↔\|{pa};$$
in other words, we just drop the ``\|p'', except in the case of ``\|{px}''
(since a variable can't be named ``$x$''). Variable $m$ is used to stand for the
x-height, since a line at this height is traditionally called the ``mean
line.'' The baseline of each character is
row 0, so the bottom pixel of a letter like ``h'' has $y$-coordinate 0. The
top pixel of an ``h'' is in row $h$, which is always an integer.\xskip
(Note that there are actually $h+1$ occupied rows, not $h$, although $h$ is
called the h-height.)\xskip The top pixel of an ``m'' is in row $m$, and the
bottom pixels of the descender letters (g,j,p,q,y) appear in row $-d$.
All three of these variables $(h,m,d)$ are integers, and so is the overshoot variable
$o$ (which is used as a correction to $h$, $m$, or $d$ in certain cases).
Variable $e$ is either an integer or an integer plus $1\over2$, whichever is
better for a pen of the \&{hpen} height, since the bar of an ``e'' is drawn with
an \&{hpen} and its $y$-coordinate is $e$. Variable $b$ is an integer calculated
in such a way that tall characters can run up to row $h+b$ and deep characters
can descend to row $-d-b$; more precisely, it is the smallest integer such that
$h+d+2b+1$ rows of the raster occupy a vertical distance that exceeds or equals
the true point size $\|{ph}+\|{pd}+2\|{pb}$.
The pen sizes in Computer Modern programs for individual letters are
generally expressed in terms of the following variables, each of which has a
positive integer value intended to approximate the ``true'' infinite-resolution
value (and slightly increased in order to look right on the output device):
$$\halign{\hskip 5em$w↓#,$ ⊗#\hfill\cr
0⊗the hairline width;\cr
1⊗the stem width;\cr
2⊗the curve width;\cr
3⊗the dot diameter;\cr
4⊗the upper-case stem width;\cr
5⊗the upper-case curve width;\cr
6⊗the hairline height;\cr
7⊗the stem height;\cr
8⊗the upper-case stem height.\cr}$$
Note that the last three of these variables have no ``\|p-variable'' equivalent;
they satisfy the approximate relation
$$w↓0/w↓6\approx w↓1/w↓7\approx w↓4/w↓8\approx\|{aspect}.$$
The \&{hpenht} is $w↓6$ and the \&{vpenwd} is $w↓0$. Thus, an \&{hpen} of
size $w↓0$ is equivalent to a \&{vpen} of size $w↓6$; we may call it the
``hairline pen'' for the font.
In the horizontal dimension, the Computer Modern programs make frequent use of
variable $u$, the approximate unit width when there are 18 units to an em.
The width of a character is expressed in terms of units (e.g., an ``h'' is
$10u$ wide, unless there is a serif correction $\|{sc}≠0$), and key positions
can be specified as a certain number of units from the left (e.g., the stems
of an ``h'' are centered at $2.5u$ and $7.5u$). The vertical guidelines in
\fig E-1 indicate the unit spacing for a 13-unit-wide ``A'' and a 12-unit-wide
``B''.
If the character is $t$ units wide, variable $u$ has been calculated so that
$t$ times $u$ is an integer $r$, the rightmost column of the character.\xskip
(The value of $u$ itself is usually not an integer, nor need $t$ be an integer.)\xskip
Just as a character typically occupies rows 0 through $h$, inclusive, in the vertical
direction, we use columns 0 through $r$ inclusive in the horizontal direction,
although most characters leave white space at the left and right boundaries.
The integer $r$ is calculated so that $r+2$ is the nearest integer to the
character's true width ($t{\cdot}\|{pu}{\cdot}\|{pixels}$); the reason for this
extra ``${+\ }2$'' is that low-resolution devices should keep a blank column
(column $r+1$) between adjacent characters. However, it is best for conceptual
purposes to think of $r$ as the character's actual width, and to think of
``$r-2.5u$'' as a point 2$1\over2$ units from the right edge, etc.
We're ready now to look more closely at a program for the upper-case letter
``A'' (\fig E-2). The first line of that program simply gives the title that will
appear on proof sheets, or possibly on the terminal when the character is
being drawn. Then comes a call to the \|{charbegin} subroutine, with seven
parameters: the character code, the width of the character in units, the
multiples of \|{sc} that are to be trimmed from the left and right, and
the character's height, depth, and italic correction. These last three parameters
must be in absolute units of printers' points, hence \|{ph} (not $h$)
is used here for the height.
\def\boxit#1{\vbox{\hrule\hbox{\vrule\hskip 6pt
\vbox{\vskip 6pt #1 \vskip 6pt}\hskip 6pt\vrule}\hrule}}
\def\fil{\hskip 0pt plus 1000pt}
\def\com{\hskip 0pt plus 1000pt$\%$ }
\save4\vbox{\halign{\hbox to 330pt{#}\cr
{\tt"}The letter A{\tt"};\fil\cr
\&{call} \|{charbegin}({\≡≡`A≡\}$,13,2,2,\|{ph},0,0)$;\fil\cr
\&{hpen};\fil\cr
$\&{lft}↓0x↓1=\&{round }1.5u;\quad\&{bot}↓0y↓1=0;$\fil\cr
$\&{rt}↓5x↓4=\&{round}(r-1.5u);\quad\&{bot}↓5y↓4=0;$\fil\cr
$\&{top}↓0y↓3=\&{top}↓5y↓2=h+o;$\fil\cr
$x↓3-x↓1=x↓4-x↓2;\quad\&{rt}↓5x↓2=\&{rt}↓0x↓3;$\fil\cr
$w↓5\;\draw2\to4;$\com right diagonal stroke\cr
$y↓5=y↓6=e$;\fil\cr
$x↓5-1=(y↓5-y↓1)/(y↓3-y↓1)\,[x↓1,x↓3]$;\fil\cr
$x↓6+1=(y↓6-y↓4)/(y↓2-y↓4)\,[x↓4,x↓2]$;\fil\cr
$w↓0\;\draw 5\to6;$\com bar line\cr
\&{lpen\hash};\quad$w↓5\;\draw3\to5;$\com erase excess at upper left\cr
\&{hpen};\quad$w↓0\;\draw3\to1;$\com left diagonal stroke\cr
\&{if} $\|{ucs}≠0:$\fil\cr
\hskip 2em$\&{call}\,\hbox{\≡≡`a≡\}\;\|{serif}(1,0,3,-.5\|{ucs});$\fil\cr
\hskip 2em$\&{call}\,\hbox{\≡≡`b≡\}\;\|{serif}(1,0,3,+\|{ucs});$\com left serifs\cr
\hskip 2em$\&{call}\,\hbox{\≡≡`c≡\}\;\|{serif}(4,5,2,-\|{ucs});$\fil\cr
\hskip 2em$\&{call}\,\hbox{\≡≡`d≡\}\;\|{serif}(4,5,2,+.5\|{ucs});$\com right serifs\cr
\&{fi}.\fil\cr}}
\topinsert{\ctrline{\boxit{\box4}}
\vskip 6pt
\ninepoint\ctrline{{\bf Fig. E--2.}\xskip A \MF\ program for upper-case ``A''.}}
The next few lines give eight equations to define the locations of points
1, 2, 3, and 4. First point 1 is positioned so that, using an \&{hpen} of size
$w↓0$ (the hairline pen), the pen's left edge will be 1.5 units from the
left edge of the character, and the bottom will be on the baseline. Similarly
point 4 is placed so that the pen's right edge will be 1.5 units from the
right edge of the character and the bottom will be on the baseline, where this
time the pen is an \&{hpen} of size $w↓5$.\xskip(The upper-case curve width
$w↓5$ is used here in preference to the stem width $w↓4$, since a diagonal
stroke tends to decrease the effective pen width.)\xskip
The positioning of points 2 and 3 is more interesting: the idea is that we
want to draw a line from 2 to 4 with an \&{hpen} of width $w↓5$, and another from
3 to 1 with an \&{hpen} of width $w↓0$. First we define $y↓2$ and $y↓3$
so that the top occurs at the h-height $h$, plus the ``overshoot'' $o$ that
gives this letter a touch of class. Then we state that $x↓3-x↓1=x↓4-x↓2$, so
that the two diagonal strokes will have the same slopes (the same amount of
change in the $x$ direction). Finally we stipulate that $\&{rt}↓5x↓2=\&{rt}↓0x↓3$,
so that the line from 2 to 4 will have the same top right boundary as the
line from 1 to 3. These equations give \MF\ enough information to determine
points 2 and 3 uniquely.
After drawing the right diagonal stroke, we need to erase part of the stem line
at the top, where it protrudes to the left of the left stroke (which is
thinner). Before erasing anything, however, we may as well draw the bar line.
Computer Modern fonts place this line at the e-height, the same level as the bar line in
an ``e'', hence $y↓5=y↓6=e$. The calculation of $x↓5$ and $x↓6$ is slightly
trickier; $x↓5$ lies between $x↓1$ and $x↓3$, and the ratio of its distance
is the same as the same as the ratio of $y↓5-y↓1$ to $y↓3-y↓1$. The equation
``$x↓5=(y↓5-y↓1)/(y↓3-y↓1)\,[x↓1,x↓3]$'' would almost surely work to define a
suitable point; but the program actually uses $x↓5-1$ instead of $x↓5$, just to
be absolutely safe against weird possibilities of rounding that might
cause the bar line to stick out at the left.\xskip(It doesn't hurt to start a
line one pixel to the right of a point that lies on another line.)
Now the \&{lpen\hash} is used to erase unwanted black pixels, changing them
back to white. Actually this erases more than we wanted to get rid of,
since it has a rectangular shape and we are erasing at an angle; but that
doesn't matter, because the left diagonal stroke blackens all the necessary
pixels.\xskip(Note that the eraser has also done away with part of the
guidelines in \fig E-1.)
Finally the \|{serif}{\hskip-1pt}
subroutine is used to attach fancy serifs at points 1 and
4; these serifs extend $.5\|{ucs}$ units outwards
and \|{ucs} units inwards. Details of this subroutine appear below.
Once you understand this program for ``A'', you will have no trouble
writing programs for ``V'' and ``v'', as well as for the Greek letter ``$\Lambda$'';
and you will be well
on your way to having ``M'' and ``W''. Similarly, the code for ``B'' in \fig E-3,
which is presented here without further comment, leads to ``D'' and ``P''
with little further ado.
\save4\vbox{\halign{\hbox to 330pt{#}\cr
{\tt"}The letter B{\tt"};\fil\cr
\&{call} \|{charbegin}({\≡≡`B≡\}$,12,2,0,\|{ph},0,\|{ph}{\cdot}\|{slant}-2\|{pu})$;\fil\cr
\&{hpen};\fil\cr
$\&{lft}↓4x↓1=\&{lft}↓4x↓2=\&{round }2u;\quad\&{top}↓4y↓1=h;\quad
\&{bot}↓4y↓2=0;$\fil\cr
$w↓4\;\draw1\to2;$\com stem\cr
\&{if} $\|{ucs}≠0$:
$\&{call}\,\hbox{\≡≡`a≡\}\;\|{serif}(1,4,2,-\|{ucs});$
$\&{call}\,\hbox{\≡≡`b≡\}\;\|{serif}(1,4,2,.5\|{ucs});$
\com upper serif\cr
\hskip2em
$\&{call}\,\hbox{\≡≡`c≡\}\;\|{serif}(2,4,1,-\|{ucs});$
$\&{call}\,\hbox{\≡≡`d≡\}\;\|{serif}(2,4,1,.5\|{ucs});$
\com lower serif\cr
\&{fi};\fil\cr
$x↓3={1\over2}[2u,r];\quad y↓3=y↓1;$\fil\cr
$\&{rt}↓5x↓4=\&{round}(r-u);\quad y↓4=\&{good}↓0\,{1\over2}h;$\fil\cr
$w↓0\;\draw 1\to3;$\com upper bar line\cr
$\&{call}\,\hbox{\≡≡`e≡\}\;\|{darc}(3,4,w↓5);$\com upper bowl\cr
$x↓5=x↓1;\quad x↓6=x↓3+{1\over2}u;\quad y↓4=y↓5=y↓6;$\fil\cr
$\&{rt}↓5x↓7=\&{round}(r-{1\over2}u);\quad\&{bot}↓5y↓7=0;$\fil\cr
$w↓0\;\draw 5\to6;$\com middle bar line\cr
$\&{call}\,\hbox{\≡≡`f≡\}\;\|{darc}(6,7,w↓5);$\com lower bowl\cr
$x↓8=x↓6;\quad y↓8=y↓7;\quad w↓0\;\draw2\to8.$\com lower bar line\cr}}
\topinsert{\ctrline{\boxit{\box4}}
\vskip 6pt
\ninepoint\ctrline{{\bf Fig. E--3.}\xskip A \MF\ program for upper-case ``B''.}}
\danger We shall now plunge into the deepest level, the
subroutines in {\tt cmbase.mf} that
take care of nasty details. Four of the most important subroutines are
given here, as examples of how this level operates; the four subroutines
(\|{fontbegin}, \|{charbegin}, \|{serif}, and \|{darc}) suffice to do
everything required by the programs for ``A'' and ``B''.
\yyskip
\halign{\hbox to size{#}\cr
$\|{eps}=.000314159;$\com a very small random positive number\cr
\&{if} $\|{mode}=0$: \&{proofmode}; \&{drawdisplay}; $\|{pixels}=36$;
$\|{blacker}=0$;\fil\cr
\hbox to 3em{\&{else}:\hfill}\&{if} $\|{mode}=1$: \&{fntmode}; \&{tfxmode};
\&{chardisplay}; $\|{pixels}=3.6$; $\|{blacker}=1.2$;\fil\cr
\hskip 3em\&{else}: \&{crsmode}; \&{tfxmode}; \&{titletrace};
$\|{pixels}=73.7973$; $\|{blacker}=1$;\fil\cr
\hskip 3em\&{fi};\fil\cr
\&{fi};\fil\cr}
\yskip\halign{\hbox to size{#}\cr
\&{subroutine} \|{fontbegin}:\com Initialize before making a font:\cr
\&{no eqtrace};\com Shut off tracing within this subroutine.\cr
\&{new} \|{typesize};\com the vertical size of the font\cr
\&{new} \|{cf};\com conversion factor, approximately equal to \|{pixels}\cr
\&{new} $h,d,m,e,o,b,s,a$;\com raster-oriented vertical dimensions\cr
\&{new} $w↓0,w↓1,w↓2,w↓3,w↓4,w↓5,w↓6,w↓7,w↓8$;\com raster-oriented pen sizes\cr
$w↓0=\&{round}(\|{pixels}{\cdot}\|{pw}+\|{blacker})$;\fil\cr
$w↓1=\&{round}(\|{pixels}{\cdot}\|{pwi}+\|{blacker})$;\fil\cr
$w↓2=\&{round}(\|{pixels}{\cdot}\|{pwii}+\|{blacker})$;\fil\cr
$w↓3=\&{round}(\|{pixels}{\cdot}\|{pwiii}+\|{blacker})$;\fil\cr
$w↓4=\&{round}(\|{pixels}{\cdot}\|{pwiv}+\|{blacker})$;\fil\cr
$w↓5=\&{round}(\|{pixels}{\cdot}\|{pwv}+\|{blacker})$;\fil\cr
$w↓6=\&{round}(\|{pixels}{\cdot}\|{pw}/\|{aspect}+\|{blacker})$;\fil\cr
$w↓7=\&{round}(\|{pixels}{\cdot}\|{pwi}/\|{aspect}+\|{blacker})$;\fil\cr
$w↓8=\&{round}(\|{pixels}{\cdot}\|{pwiv}/\|{aspect}+\|{blacker})$;\fil\cr
\&{hpenht} $w↓6$;\quad \&{vpenwd} $w↓0$;\fil\cr}
\yskip\halign{\hbox to size{#}\cr
$\|{typesize}=\|{ph}+\|{pd}+2\|{pb};\quad\|{cf}{\cdot}\|{typesize}=\|{pixels}{\cdot}
\|{typesize}-1;$\fil\cr
$h=\&{round}\,\;\|{cf}{\cdot}\|{ph};\quad d=\&{round}\,\;\|{cf}{\cdot}\|{pd};\quad
m=\&{round}\,\;\|{cf}{\cdot}\|{px};$\fil\cr
$o=\&{round}\,\;\|{cf}{\cdot}\|{po};\quad s=\|{cf}{\cdot}\|{ps};\quad
a=.5\,\&{round}\,\;2\|{cf}{\cdot}\|{pa};$\fil\cr
$b=-\&{round}\biglp.5(h+d-\|{typesize}{\cdot}\|{pixels})\bigrp;$\fil\quad
\&{hpen};\quad$e=\&{good}↓0\,\;\|{cf}{\cdot}\|{pe};$\fil\cr}
\yskip\halign{\hbox to size{#}\cr
\&{maxht} $h+b$;\fil\cr
\&{trxy} \|{slant};\fil\cr
\&{if} $\|{mode}≠0$: \&{texinfo} $\|{slant},6\|{pu},3\|{pu},3\|{pu},\|{px},18\|{pu},
2\|{pu}$;\fil\cr
\&{fi}.\fil\cr}
\yyskip
\halign to size{\hfill#\tabskip 0pt plus 100pt⊗\hfill$\%$ #\tabskip 0pt\cr
\&{subroutine} \|{charbegin}(\&{var} \|{charno})⊗seven-bit character code\cr
(\&{var} \|{charuw})⊗character width in units\cr
(\&{var} \|{lftcorr}, \&{var} \|{rtcorr})⊗serif-oriented corrections in units\cr
(\&{var} \|{charh}, \&{var} \|{chard}, \&{var} \|{chari})\spose:⊗\&{charht}, \&{chardp},
\&{charic} values in points\cr}
\yskip
\halign{\hbox to size{#}\cr
\&{no eqtrace}; \&{no calltrace};\com Shut off tracing in this subroutine.\cr
\&{new} \|{uw};\com the correct character width in units\cr
\&{new} $r$;\com raster-oriented character width\cr
\&{new} $u$;\com raster-oriented design unit\cr
\&{new} \|{tu};\com unmodified raster-oriented unit\cr
\&{new} \|{italcorr};\com italic correction\cr
\&{if} $\|{chari}≥0$: $\|{italcorr}=\|{chari}$; \&{else}: $\|{italcorr}=0$;\fil\cr
\&{fi};\fil\cr
\&{charcode} \|{charno};
\&{charht} \|{charh}; \&{chardp} \|{chard}; \&{charic} \|{italcorr};\fil\cr
$\|{tu}=\|{pu}{\cdot}\|{pixels}$;\fil\cr
\&{if} $\|{fixwidth}=0$: $r+2=\&{round}\,\;\|{charuw}{\cdot}\|{tu}$;\fil\cr
\hskip 3em $\|{uw}=\|{charuw}-\|{sc}{\cdot}(\|{lftcorr}+\|{rtcorr})$;\fil\cr
\&{else}: $r+2=\&{round}\biglp(9+\|{sc}{\cdot}(\|{lftcorr}+\|{rtcorr})){\cdot}\|{tu}\bigrp$;\fil\cr
\hskip 3em $\|{uw}=9$;\fil\cr
\&{fi};\fil\cr
$u{\cdot}\|{charuw}=r$;
\&{charwd} $\|{uw}{\cdot}\|{pu}$; \&{chardw} $\|{uw}{\cdot}\|{tu}$;\fil\cr
\&{incx} $\&{round}(-\|{sc}{\cdot}\|{lftcorr}{\cdot}\|{tu})$;\fil\cr
\&{if} $\|{mode}=0$: \&{call} $\|{box}(\&{round}\,\;\|{sc}{\cdot}\|{lftcorr}{\cdot}\|{tu})$;\fil\cr
\&{fi}.\fil\cr}
\yyskip
\halign{\hbox to size{#}\cr
\&{subroutine} \|{box}(\&{var} \|{offset}):\com Draw guildelines and box around a
character:\cr
\&{no drawtrace}; \&{no proofmode};\fil\cr
\&{new} $\|{topp},\|{bott},\|{left},\|{right},\|{pos};$\fil\cr
$\|{topp}=h+b;\quad\|{bott}=-d-b;$\fil\cr
$\|{left}=\|{offset};\quad\|{right}=\|{offset}+u{\cdot}\|{uw};$\fil\cr
$x↓1=x↓3=x↓5=x↓7=x↓9=x↓{11}=x↓{13}=x↓{15}=x↓{17}=\|{left};$\fil\cr
$x↓2=x↓4=x↓6=x↓8=x↓{10}=x↓{12}=x↓{14}=x↓{16}=x↓{18}=\|{right};$\fil\cr
$y↓1=y↓2=0;\quad\&{cpen};\quad 1\;\draw1\to2;$\com baseline\cr
$y↓3=y↓4=e;\quad\draw3\to4;$\com e-height\cr
$y↓5=y↓6=m;\quad\draw5\to6;$\com mean line (x-height)\cr
$y↓7=y↓8=h;\quad\draw7\to8;$\com h-height\cr
$y↓9=y↓{10}=\|{topp};\quad\draw9\to10;$\com top of character\cr
$y↓{11}=y↓{12}=-d;\quad\draw11\to12;$\com descender line\cr
$y↓{13}=y↓{14}=\|{bott};\quad\draw13\to14;$\com bottom of character\cr
\&{trxy} 0;\com Temporarily turn off the slant.\cr
$y↓{15}=y↓{16}=\|{topp};\quad y↓{17}=y↓{18}=\|{bott};$\fil\cr
$\draw15\to17;\quad\draw16\to18;$\com left and right edges\cr
\&{if} $\|{italcorr}>0$: $x↓{19}=x↓{20}=\|{right}+\|{italcorr}{\cdot}\|{pixels};$\fil\cr
\hskip 3em$y↓{19}=\|{topp};\quad y↓{20}=0;\quad\draw19\to20;$\com show
italic correction\cr
\&{fi};\fil\cr
\&{trxy} \|{slant};\com Restore slanted transformation\cr
$\|{pos}=0;\quad\&{call}$ \|{unitlines}.\com
Draw the unit guidelines.\cr}
\yyskip
\halign{\hbox to size{#}\cr
\&{subroutine} \|{unitlines}:\com Recursive subroutine to draw guidelines:\cr
$x↓1=x↓2=\|{pos};\;y↓1=\|{topp};\;y↓2=\|{bott};\;\&{cpen};$\fil\cr
\&{if} $\|{pos}≥\|{left}$: $1\;\draw1\to2;$\fil\cr
\&{fi};\fil\cr
\&{new} $\|{pos}$;
$\|{pos}=x↓1+u;$\fil\cr
\&{if} $\|{pos}≤\|{right}$: \&{call} \|{unitlines};\fil\cr
\&{fi}.\fil\cr}
\yyskip
\halign to size{\hfill#\tabskip 0pt plus 100pt⊗\hfill$\%$ #\tabskip 0pt\cr
\&{subroutine} \|{serif}(\&{index} $i$)⊗point where serif appears\cr
(\&{index} $k$)⊗$w$-variable for stem line\cr
(\&{index} $j$)⊗another point on the stem line\cr
(\&{var} \|{sl})\spose:⊗serif length\cr}
\yskip
\halign{\hbox to size{#}\cr
$y↓1=y↓i;$\fil\cr
\&{if} $y↓i<y↓j$: $y↓2=y↓i+s$; \quad\&{else}: $y↓2=y↓i-s$;\fil\cr
\&{fi};\fil\cr
\&{hpen};\fil\cr
\&{if} $\|{sl}<0$: $\&{lft}↓0x↓1=\&{lft}↓kx↓i+\|{sl}{\cdot} u-\|{eps};$\fil\cr
\hskip 3em$\|{lft}↓0x↓2=\&{lft}↓k(y↓2-y↓i)/(y↓j-y↓i)\,[x↓i,x↓j];$\fil\cr
\&{else}: $\&{rt}↓0x↓1=\&{rt}↓kx↓i+\|{sl}{\cdot} u+\|{eps};$\fil\cr
\hskip 3em$\|{rt}↓0x↓2=\&{rt}↓k(y↓2-y↓i)/(y↓j-y↓i)\,[x↓i,x↓j];$\fil\cr
\&{fi};\fil\cr
\&{no proofmode};\fil\cr
$x↓3={1\over3}\hbox{\:a[}x↓1-\|{sl}{\cdot} u,{1\over2}[x↓1,x↓2]\hbox{\:a]};\quad
y↓3={1\over3}\hbox{\:a[}y↓i,{1\over2}[y↓1,y↓2]\hbox{\:a]};$\fil\cr
\&{minvr} 0; \&{minvs} 0;\fil\cr
$w↓0\;\ddraw1\{x↓i-x↓1,0\}\to3\to2\{x↓j-x↓i,y↓j-y↓i\},\;\;1\to1\to i;$\fil\cr
\&{minvr} 0.5; \&{minvs} 0.5.\fil\cr}
\yyskip
\halign to size{\hfill#\tabskip 0pt plus 100pt⊗\hfill$\%$ #\tabskip 0pt\cr
\&{subroutine} \|{darc}(\&{index} $i$)⊗starting point\cr
(\&{index} $j$)⊗opposite corner point\cr
(\&{var} \|{maxwidth})\spose:⊗the pen grows from $w↓0$ to this size\cr}
\yskip
\halign{\hbox to size{#}\cr
$x↓5=x↓i;\quad x↓2=x↓4=1/\|{sqrttwo}\,[x↓i,x↓j];\quad x↓3=x↓j;$\fil\cr
$y↓5=y↓j;\quad y↓3={1\over2}[y↓i,y↓j];$\fil\cr
$y↓2=1/\|{sqrttwo}\,[y↓3,y↓i];\quad y↓4=1/\|{sqrttwo}\,[y↓3,y↓j];$\fil\cr
$\&{hpen};\quad \draw |w↓0|i\{x↓3-x↓i,0\}
\to|{2\over3}[w↓0,\|{maxwidth}]|2\{x↓3-x↓i,y↓3-y↓i\}\to$\fil\cr
\hskip6em $|\|{maxwidth}\hbox{\tt\char'43}|3\{0,y↓3-y↓i\}\to$\fil\cr
\hskip6em $|{2\over3}[w↓0,\|{maxwidth}]|
4\{x↓5-x↓3,y↓5-y↓3\}\to|w↓0|5\{x↓5-x↓3,0\}.$\fil\cr}
\vfill
\specialappbegin F. {Font information for \TEX}
{\def\`{{\tt\char'15}}\def\'{{\tt\char'16}}
The \TEX\ typesetting system assumes that some ``intelligence'' has been built
into the fonts it uses. In other words, information stored with \TEX's fonts
has an important effect on \TEX's behavior. This has two consequences for
people who use \TEX:\xskip(a) Typesetting is more flexible, since fewer
conventions are frozen into the computer program.\xskip(b) Font designers have
to work a little harder, since they have to tell \TEX\ what to do. The
purpose of this appendix is to explain how you, as a font designer, can cope
with (b) in order to achieve spectacular success with (a).\xskip(You should
of course be somewhat familiar with \TEX\ if you expect to provide it with
the best information.)
\ninepoint\yskip
In the first place, \TEX\ needs to know how big a box each character is
supposed to occupy, since \TEX\ is based on the primitive concepts of boxes and
glue. When it typesets a word like ``box'', it places the first letter ``b''
in such a way that the \MF\ pixel whose $x$ and $y$ coordinates are $(0,0)$
will appear on the baseline of the current horizontal line being typeset, at the
left edge of the ``b'' box. The second letter ``o'' is placed in a second box
adjacent to the first one, so it is obvious that we must tell \TEX\ how wide
to make the ``b''. In fact, \TEX\ also learns how tall the ``b'' box should be;
this affects the placement of accents, if you wish to write ``\s b\s o\s x'',
and it also avoids overlap with unusual constructions in an adjacent line.
A total of four dimensions is given for each character of a font to be used by
\TEX, in units of printers' points:
\def\¬{\yskip\hangindent 38pt$ $}
\¬\&{charwd}, the width of the box containing the character.
\¬\&{charht}, the height (above the baseline) of the box containing the character.
\¬\&{chardp}, the depth (below the baseline) of the box containing the character.
\¬\&{charic}, the ``italic correction''. This amount is added to the width of the
box (at the righthand side) in two cases:\xskip(a) When a \TEX\ user specifies
an italic correction (``{\≡\/≡\}'') immediately following this character, in
horizontal mode.\xskip(b)\penalty999\ Whenever this character is used in math mode, unless
it has a subscript but no superscript.\xskip(For example, the italic correction
is applied to $P$ in the formulas $P(x)$ and $P↑2$, but not in the formula
$P↓n$.)
\yskip\noindent If you don't specify one or more of these four dimensions,
\MF\ assumes that you intended any missing dimensions to be zero. For example,
the italic correction for most letters in non-slanted fonts is zero, so you
needn't say anything about it.
It is important to note the difference between \&{charwd} (the width of the
character box) and \&{chardw} (the character's device width, discussed in
Chapter 9). The former is given
in units of points, and it affects \TEX's positioning of text, while the latter
is an integer number of pixels that has no influence on the appearance of
\TEX\ output. The purpose of \&{chardw} is merely to compress the data that
\TEX\ transmits to a typesetting machine; for example, \TEX\ needn't specify
where to put the ``o'' following a ``b'', in the common case that the
typesetting device will figure the correct position by its knowledge of
the approximate size \&{chardw}. Furthermore \&{chardw} is the width of the
character if for some reason you are (shudder) typesetting something without using \TEX.
\yskip
The next kind of information that \TEX\ wants is concerned with pairs of adjacent
characters within a font, namely the data about ligatures and kerning. For
example, \TEX\ moves the ``x'' slightly closer to the ``o'' in the word ``box'',
because of information stored in the font you are now reading. Otherwise (if the
three boxes had simply been placed next to each other according to their
\&{charwd}) the word would have been ``bo{}x'', which looks slightly less
attractive. Similarly there is a diff\hskip-.05555em erence
between ``diff\hskip-.05555em erence'' and % This cheating is temporary (font wrong)
``dif{}ference'', because the font tells \TEX\ to substitute the ligature ``ff''
when there are two f's in a row.
Ligature and kerning information is specified by giving \TEX\ short
programs to follow. For example, the font you are now reading includes
the following programs (among others):
$$\vbox{\halign{#\hfill\cr
\&{lig} \`f: \`i = \'174, \`f = \'173, \`l = \'175;\cr
\&{lig} \'173: \`i = \'176, \`l = \'177;\cr
\&{lig} \`V: \`F: \`A \&{kern} $-2.5$\|{ru},\cr
\qquad \`X: \`K: \`O \&{kern} $-.5$\|{ru}, \`C \&{kern} $-.5$\|{ru},\cr
\qquad\qquad\qquad \`G \&{kern} $-.5$\|{ru}, \`Q \&{kern} $-.5$\|{ru};\cr}}$$
information like this can appear anywhere in a \MF\ program after \&{tfxmode}
has been specified. Both ligatures and kerns are introduced by the keyword
\&{lig}, and this example can be paraphrased as follows:
\def\@{\hskip-1pt}
\yskip\hsize 27pc\hangindent 2pc after 0\noindent
Dear \TEX, when you are typesetting an ``f\/'' with this font, and when the
following character also belongs to this font, do this: If the following
character is an ``i'', change the ``f\/'' to character code octal {\it 1\@74}
[namely ``fi''] and delete the ``i''; if it is an ``f\/'' or ``l'', similarly
change the pair of characters to octal {\it 1\@73} [``ff\/''] or {\it 1\@75}
[``fl'']. When you are typesetting character code {\it1\@73} [`ff\/''] and the
next character is an ``i'' or ``l'', change to codes {\it1\@76} [``ffi''] or
{\it1\@77} [``ffl'']. When you are typesetting a ``V'' or an ``F'' and the
next character is an ``A'' in this font, delete $2.5$\|{ru} of space before
the ``A''.\xskip[Variable \|{ru} has been defined elsewhere in the program to
be $1\over18$ of a quad, i.e., $10\over18$ of a point in 10-point type.]\xskip
If the next character is ``O'' or ``C'' or ``G'' or ``Q'', delete $1\over2$\|{ru}
of space between the letters. These last four instructions apply after ``X''
and ``K'' as well as after ``V'' and ``F''.
\hsize 29pc\yskip
The general form of ligature/kerning statements is
$$\hbox{\&{lig} \<lig instruction list\>}$$
where \<lig instruction list\>\ is a list of one or more \<lig instruction\>s.
There are three kinds of \<lig instruction\>s, which may appear intermixed
in any order:
\def\¬#1){\yskip\textindent{#1)}\hangindent 38pt\!}
\¬1) Labels, having the form ``\<expression\>:''.
The \<expression\>\ is usually a constant, as in our examples above; it denotes
a character code, which is rounded to an integer that should be between 0 and
127 (octal {\it1\@77\/}). At most one label should appear for each character code.
The label means that the ligature/kerning program for the specified character
starts here. Note that the program for characters \`X and \`K in our example
starts in the middle of the program for characters \`V and \`F, while the latter
two letters have identical programs; this device saves space inside \TEX, and
it also saves time since \TEX\ has fewer instructions to load with the fonts.
\¬2) Ligature replacements, having the form
``\<expression$↓1$\>\ = \<expression$↓2$\>''. Both \<expression\>s are rounded to integers
that should be between 0 and 127; they are usually constants. The meaning is that
if the current character is followed by the character whose code is
\<expression$↓1$\>, this pair is replaced by the character whose code is
\<expression$↓2$\>.
\¬3) Kern specifications, having the form
``\<expression$↓1$\>\ \&{kern} \<expression$↓2$\>''. The first expression is
usually constant; it is rounded to an integer that should lie between 0 and 127.
The second expression is usually negative, but it need not be. The meaning is
that if the current character is followed by the character whose code is
\<expression$↓1$\>, in the same font, additional spacing of \<expression$↓2$\>\
points is inserted between the two.
\yskip\noindent
Instructions of types (2) and (3) must be followed by commas, unless they are
the final instruction of the \<lig instruction list\>; labels, on the other
hand, are never followed by commas.
We have said that the ligature/kerning program for each character starts at the
corresponding label, but where does that program stop? Answer: It stops at the
end of the \<lig instruction list\>\ containing the label, unless the last
\<lig instruction\>\ of that list is a label, or unless that last \<lig
instruction\>\
is followed by a comma. In the latter cases, the ligature/kerning program
continues into the next \<lig instruction list\>\ that \MF\ interprets. Thus you
can use \MF's subroutines and/or conditional statements to generate
intricate patterns of ligature/kerning instructions, if you really want to.
{\sl Caution:}\xskip Novices often go overboard on kerning; restraint is
desirable. It usually works out best to kern by at most half of what looks
right to you at first, since kerning should not be noticeable by its presence
(only by its absence). Kerning that looks right in a logo often interrupts the
rhythm of reading when it appears in other textual material.
\yskip The remaining information that \TEX\ needs in a text font can be provided by
the command
$$\hbox{\&{texinfo} \<expression list\>}$$
where the \<expression list\>\ is a list of seven \<expression\>s separated by
commas. The seven \<expression\>s should contain the following data, in order:
\¬1) ``slant''. The change in $x$ coordinate per unit change in $y$ coordinate
when \TEX\ is raising or lowering an accent character.
\¬2) ``space''. The amount of space (in points) between words when using this font.
\¬3) ``stretch''. The amount of stretchability (in points) between words when
using this font, according to \TEX's notion of glue.\xskip(This is the maximum
amount of additional space that would look tolerable.)
\¬4) ``shrink''. The maximum amount of shrinkage (in points) between words when
using this font, according to \TEX's notion of glue.
\¬5) ``xheight''. The height of characters (in points) for which accents are
correctly situated. An accented character has the accent raised by the difference
between its \&{charht} and this value.
\¬6) ``quad''. The width of one {\tt em} unit (in points) when using this font.
\¬7) ``extraspace''. The amount of additional space inserted after periods when
using this font.\xskip(Strictly speaking, it is the amount added to ``space''
when \TEX's ``space factor'' exceeds 2.)
\yskip\noindent The {\tt DRAGON} example of Chapter 4 gave no \&{texinfo}, so
all seven of these parameters were set to zero in that font.
If your font is for use in \TEX\ math mode, as a {\tt mathsy} or a {\tt mathex}
font, you need to specify still more information. Otherwise, you can stop
reading this appendix, right now.
\yyskip Math symbols fonts ({\tt mathsy}) require more \&{texinfo}. In fact,
you can give several \&{texinfo} commands in a single \MF\ program, and their
\<expression list\>s can contain more then or fewer than seven \<expression\>s; each
\&{texinfo} appends one or more values to the \TEX\ information. The total number
of parameters \TEX\ uses in a {\tt mathsy} font is 22, and they must consist of
the first six above and the following additional ones in order:
\¬7) ``math space''. If this is not zero, it denotes the amount of space in points
that will be used for all nonzero space (except {\≡\quad≡\}) in math formulas:
thin spaces, thick spaces, control spaces, and op spaces, whenever these are
nonzero according to \TEX's rules. The parameter is generally zero unless \TEX\
is outputting to a fixed-width device like a typewriter or line printer.
\¬8) ``num1''. Amount to raise baseline of numerators in display styles.
\¬9) ``num2''. Amount to raise baseline of numerators in non-display styles,
except for ``{\≡\atop≡\}''.
\¬10) ``num3''. Amount to raise baseline of numerators in non-display {\≡\atop≡\}
styles.
\¬11) ``denom1''. Amount to lower baseline of denominators in display styles.
\¬12) ``denom2''. Amount to lower baseline of denominators in non-display styles.
\¬13) ``sup1''. Amount to raise baseline of superscripts in unmodified
display style.
\¬14) ``sup2''. Amount to raise baseline of superscripts in unmodified non-display
styles.
\¬15) ``sup3''. Amount to raise baseline of superscripts in modified styles.
\¬16) ``sub1''. Amount to lower baseline of subscripts if superscript is absent.
\¬17) ``sub2''. Amount to lower baseline of subscripts if superscript is present.
\¬18) ``supdrop''. Amount below top of large box to place baseline if the box
has a superscript in this size.
\¬19) ``subdrop''. Amount below bottom of large box to place baseline if the box
has a subscript in this size.
\¬20) ``delim1''. Size of {\≡\comb≡\} delimiters in display styles.
\¬21) ``delim2''. Size of {\≡\comb≡\} delimiters in non-display styles.
\¬22) ``axisheight''. Height of fraction lines above the baseline.\xskip(This is
usually midway between the two bars of an $=$ sign.)
\yskip\noindent Similarly,
a {\tt mathex} font requires 13 items of \&{texinfo}, namely the standard first
seven and the following additional things in order:
\¬8) ``defaultrulethickness''. The thickness of {\≡\over≡\} and {\≡\overline≡\}
bars.
\¬9) ``bigopspacing1''. The minimum glue space above a large displayed operator.
\¬10) ``bigopspacing2''. The minimum glue space below a large displayed operator.
\¬11) ``bigopspacing3''. The minimum distance between a limit's baseline and a
large displayed operator, when the limit is above the operator.
\¬12) ``bigopspacing4''. The minimum distance between a limit's baseline and a
large displayed operator, when the limit is below the operator.
\¬13) ``bigopspacing5''. The extra glue placed above and below displayed limits,
effectively enlarging the corresponding boxes.
\yskip\noindent If you supply fewer than 22 items of \&{texinfo} for a {\tt mathsy}
font, or fewer than 13 for a {\tt mathex} font, \TEX\ will probably do very
strange and undesirable things. So don't.
Still more information is needed in {\tt mathex} fonts. In the first place,
the italic correction for symbols used as {\≡\mathop≡\}s (e.g., summation and
integral signs) has a special significance: If it is zero, the limits for this
operator will be centered above and below the operator. If it is nonzero,
the limits will be set immediately to the right, with the lower limit shifted left
by the amount of \&{charic}.\xskip(A \TEX\ user writes {\≡\limitswitch≡\} to
reverse these conventions; when limits are set above and below the operator,
the upper limit is \&{charic} points to the right of the lower limit.)
\yskip
\hbox to size{\hfill$\left\{\quad\vcenter{\hbox par 25pc{\!
Another difference for {\tt mathex} fonts is the provision of ``built up''
symbols that can get arbitrarily large. Such symbols are manufactured from
up to four pieces, including a mandatory extension part and optional
top, middle and bottom parts. For example, the left brace at the left of this
paragraph has all four pieces, while the norm symbol at the right is made up
solely of extension pieces. Similarly, floor and ceiling brackets ($\lfloor\;
\rfloor$ and $\lceil\;\rceil$) are built up from the same components as regular
brackets, but without top or bottom, respectively. \TEX\ makes the smallest
symbol meeting a given size constraint, using zero or more copies of the
extension component. If there is a middle, the
same number of extension components will appear above and below.}}\quad
\right\char'615$\hfill}
\yskip
Suppose $c$ is the 7-bit code representing a built-up character. \TEX\
requires the following conventions:\xskip(1) The \&{charht} field
for code $c$ must be zero, and there must be no ligature program for $c$.\xskip
(2) The command
$$\hbox{\&{varchar} \<expression$↓1$\>, \<expression$↓2$\>, \<expression$↓3$\>,
\<expression$↓4$\>}$$
is given for $c$ in lieu of a \&{charic} command, where the four \<expression\>s
stand respectively for the character codes of the top, middle, bottom, and
extension components. These codes should be zero if the component doesn't exist,
otherwise they should round to numbers between 1 and 127. For example, the
left brace symbol in font {\tt cmathx} has been defined by ``\&{varchar}
\'070, \'074, \'072, \'076''.
\xskip(Code $c$ itself
need not be any of these four.)\xskip (3) The \&{charwd} of the extension
component is taken to be the \&{charwd} of the entire built-up symbol.
One final kind of information appears in {\tt mathex} fonts, namely the lists that
tie related characters together in increasing order of their size. For example,
all of the left parentheses in {\tt cmathx} have been specified by the command
$$\hbox{\&{charlist} \'000, \'020, \'022, \'040, \'060, 0.}$$
(Cf.\ Table 7 of Appendix F in the \TEX\ manual.)\xskip
When \TEX\ needs a variable-size left parenthesis, it looks first at
character \'000, then (if this is too small) at \'020, and so on, until either
finding one that is large enough or reaching \'060 (the end of the list). The
zero following \'060 indicates that \'060 is a built-up symbol that can
grow arbitrarily large. If the last entry of a \&{charlist} is not zero,
this symbol is not of the built-up variety, and it is used by \TEX\
whether or not it is large enough. For example, the slash symbols in
{\tt cmathx} are specified by ``\&{charlist} \'016, \'036, \'054'', the latter
being the largest slash present. A \&{charlist} in general consists of
\<expression\>s (usually constants) that are in increasing order except that
the last one may be zero. The nonzero \<expression\>s should round to
integer character codes between 1 and 127. None of these characters should
have a ligature/kern program, since \TEX\ stores the \&{charlist} information
in the same place that is usually used for ligatures and kerns.
The \&{charlist} for square root symbols should start at character position
\'160 in a {\tt mathex} font. These symbols should be designed so that they look
right when a horizontal rule of the default rule thickness is placed with
its upper left corner coinciding with the upper right corner of the character box.
}
\vfill
\specialappbegin I. {Index}
\def\index{T} \def\1{T} \def\lr{L}
\def\indexoutput{\if T\1{\gdef\1{F}\vsize31pc\hsize164pt\save1\page\gdef\2{T}}
\else{ % Not the beginning of the appendix
\if L\lr{\gdef\lr{R}\save0\page}
\else{ % Not the left-hand column
\gdef\lr{L}\save3\hbox to 348pt{\box0\hfill\page}
\if T\2{\gdef\2{F}\save3\vbox to 36pc{\box1\vskip0pt minus100000000pt
\box3}\vsize36pc}\else{}
\moveleft 10pt\vbox to 36pt{\hrule % horizontal rule at top of page
\hbox to 368pt{\trule\ifeven0{\topmark}\else{\botmark}\trule}
\hrule\vfill} % horizontal rule under the headline
\box3\advcount0} % insert the page contents
}}
This index shows all of \MF's ``reserved words'' in boldface type,
and it also lists error messages that are mentioned outside of Chapter 10.
\vfill\eject % this page will be overlapped, when \2 is T
\def\¬{\par\hangindent 16pt \noindent\!}
\def\*{\par\penalty1000\hangindent 16pt}
\def\newletter#1{\par\penalty-300
\vskip10pt plus5pt minus5pt
\hangindent 16pt\noindent\!}
\def\<{$\langle$}\def\>{$\rangle$}
\eightpoint \parindent 8pt \jpar1000 \ragged 1000 \chpar2←1000
\hangindent 16pt \noindent
Addition, 44.\¬
Alphatype, {\sl see} CRS.\¬
Angle of a curve, {\sl see} Direction.\¬
Apostrophe, 39.\¬
Arguments, 55--56, 64.\¬
Assignment operation, 60--61.
\newletter b
Bean shape, 9.\¬
Blank spaces, 40, 45.\¬
BNF notation, 45, 58.\¬
\&{bot}, 7, 28, 42.\¬
Bracket notation, 43--44, 56, 94.\¬
Built-up symbols, 100.
\newletter c
\&{call}, 56--59, 64.\¬
\&{calltrace}, 67.\¬
\<carriage-return\>, 29--30, 45.\¬
Cartesian coordinates, 4.\¬
Character width, 8.\¬
\&{charcode}, 34--35, 39, 66.\¬
\&{chardisplay}, 67.\¬
\&{chardp}, 35--36, 65, 95.\¬
\&{chardw}, 35--36, 66, 95--96.\¬
\&{charht}, 35--36, 65, 95, 98, 100.\¬
\&{charic}, 65, 95.\¬
\&{charlist}, 68, 72, 100--101.\¬
\&{charwd}, 35--36, 65, 95, 100.\¬
\&{chrmode}, 68--69.\¬
Circles, 11, 21.\¬
Circular pen, 6.\¬
Comments, 35.\¬
Computer Modern fonts, 82--94.\¬
Conditional statements, 59--60, 64.\¬
Constants, 39, 45.\¬
Contents of this manual, table, 3.\¬
Control bits, 60, 66--68.\¬
Coordinates, 4, 39, 71.\¬
\&{cosd}, 42, 81.\¬
\&{cpen}, 6, 22--23, 28, 48--50, 62.\¬
{\tt <cr>}, 30.\¬
CRS (Cathode Ray Setter), 66, 68, 71, 86.\¬
\&{crsbreak}, 67, 71.\¬
\&{crsmode}, 68--69.\¬
Cubic spline functions, 20--22, 50.\¬
Current pen size, 6, 48--50, 60.\¬
Current pen type, 22, 60, 62.\¬
Curved lines, 8--22.
\newletter d
Dangerous bend, 2.\¬
Datadisc (video terminal), 29, 67, 80.\¬
Davis, Chandler, 33.\¬
\&{ddraw}, 46--49, 51, 63, 65.\¬
Declarative language, 41.\¬
Deletion (on line), 36--37.\¬
Dependent variables, 41, 79.\¬
Descartes, Ren\'e, 4.\¬
Diamond rule, 52--53.\¬
\<digit\>, 45.\¬
Direction of a curve, 10--20, 63.
\*Explicit, 13--20.
\*Implicit, 10--13, 18, 20.\¬
Discreteness, 25--27, 51--55.\¬
Division, 43.\¬
Double drawing, 46--49, 51.\¬
{\tt DRAGON}, 33--38.\¬
Dragon curve, 33, 35.\¬
\&{draw}, 6, 8--22, 49--53, 63.\¬
\&{drawdisplay}, 29, 67.\¬
\&{drawtrace}, 67.\¬
\&{dumplength}, 66.\¬
\&{dumpwindow}, 66.
\newletter e
Ellipses, 12, 21.\¬
Elliptical pens, 22--25.\¬
\&{else}, 59, 64.\¬
\&{end}, 33, 38.\¬
\&{epen}, 27--28, 48--49, 63, 65, 81.\¬
\&{epenxcorr}, 27, 65.\¬
\&{epenxfactor}, 27, 65, 72.\¬
\&{epenycorr}, 27, 65.\¬
\&{epenyfactor}, 27, 65, 72.\¬
\&{eqtrace}, 41, 66.\¬
Equations, 5--6, 31--33, 39--46, 62.\¬
Erasers, 24, 27--28, 62, 90.\¬
Errors, 29--33, 36--38, 69--80.\¬
{\tt errors.tmp}, 33.\¬
{\tt ETC}, 66.\¬
Exercises, answers, 3, 81.\¬
Explicit directions for a curve, 13--20.\¬
Explicit pens, 27--28.\¬
Expressions, 42--45.\¬
Extreme points, 16, 19, 54.
\newletter f
\&{fi}, 59, 64.\¬
File names, 37, 69, 74.\¬
Filling in between curves, 46--51.\¬
\&{fntmode}, 34, 68--69.\¬
Fontomania, 7.\¬
Full stop, 46
\newletter g
Global variables, 56, 61.\¬
\&{good}, 42, 54--55.
\newletter h
$h↓0$, 22--23, 28, 48.\¬
Heart, 12--17, 23, 47.\¬
Heart and sole, 23.\¬
Hein, Piet, 58\¬
Hidden points, 12; {\sl see also} \&{invisible}.\¬
Horizontal extrema, 16, 19, 54.\¬
\&{hpen}, 22--23, 28, 48--50, 62, 65.\¬
\&{hpenht}, 23, 65, 88.
\newletter i
\<identifier\>, 39, 45, 55.\¬
\&{if}, 59--60, 64.\¬
Implicit directions for a curve, 10--13, 18, 20.\¬
``{\tt ! Inconsistent equation}'', 33, 73.\¬
\&{incx}, 51, 64--65, 67.\¬
\&{incy}, 51, 64--65, 67.\¬
Independent variables, 41, 62, 79.\¬
``{\tt ! Indeterminate relation}'', 60, 73.\¬
\&{index}, 56, 58, 64.\¬
\<index\>, 40, 42, 45.\¬
Index arguments, 57, 59.\¬
Inflection points, 18--19.\¬
\&{input}, 68--69.\¬
``{\tt ! Input page ended}'', 37--38, 73.\¬
Insertion (on line), 37--38, 70.\¬
Intersection of straight lines, 44.\¬
Invariance property of \MF\ curves, 10.\¬
\&{invisible}, 68.\¬
Italic correction, 65, 92, 95, 100.\¬
Iterations, 60.
\newletter k
\&{kern}, 96--97.\¬
Kerning, 96--98.\¬
Known variables, 41, 79.\¬
Knuth, Donald Ervin, 1, 12, 17, 33, 61.\¬
Knuth, Jill Carter, 33.
\newletter l
Labels of points, 57--59, 61, 67--68.\¬
{\tt <lf>}, 30.\¬
\&{lft}, 8, 28, 42, 54.\¬
\&{lig}, 68, 96--97.\¬
Ligatures, 96--97.\¬
Local variables, 56, 61.\¬
Locality property of \MF\ curves, 10.\¬
``{\tt ! Lookup failed}'', 37, 74.\¬
\&{lpen}, 24, 28, 48--50, 62.
\newletter m
{\tt mathex} font for \TEX, 99--101.\¬
{\tt mathsy} font for \TEX, 98--99.\¬
\&{maxht}, 34, 66, 71.\¬
\&{maxvr}, 22, 65.\¬
\&{maxvs}, 22, 65.\¬
\MF, meaning of, 4.\¬
{\tt mfput}, 33, 69.\¬
\&{minvr}, 22, 65.\¬
\&{minvs}, 22, 65.\¬
``{\tt ! Missing = sign}'', 30--31, 75.\¬
\&{modtrace}, 66--67, 77, 79.\¬
Multiplication, 30--31, 43, 46.
\newletter n
Names of points, 57--59, 61.\¬
\&{new}, 33, 44, 60, 62, 73.\¬
\&{no}, 38, 60, 66.\¬
\&{nrand}, 42, 65.\¬
\&{nseed}, 65.\¬
Null statement, 62.
\newletter o
Oblique pen, 25.\¬
On-line error correction, 36--38, 70.
\newletter p
\&{pagewarning}, 38, 64, 66--67, 74.\¬
Parameters, 55--56, 64.\¬
Parentheses, 46, 58.\¬
\<path\>, 63.\¬
\&{pause}, 67.\¬
Pen size, 6--7, 22, 56.\¬
\&{penreset}, 60, 66--67.\¬
Pens, 22--28, 62--63.\¬
Period, 40, 45--46, 61--62.\¬
Pixels (picture elements), 51.\¬
Plotting points, 26--28, 52--53.\¬
\&{plottrace}, 67.\¬
Points, 4--5, 39.
\*names of, 57--59, 61.\¬
Primary expressions, 42.\¬
Product, 30--31, 43.\¬
\&{proofmode}, 29, 32, 57, 61, 64, 67--69.
\newletter q
Quoted strings, 34--35, 45, 64, 77.
\newletter r
Raster, 1, 5, 51--54.\¬
Recursion, 59--60, 93.\¬
``{\tt ! Redundant equation}'', 32, 76.\¬
Reflection symmetry, 53.\¬
\<relation\>, 59--60.\¬
Reserved words, 39.\¬
Reverse apostrophe, 39.\¬
\&{round}, 42, 46, 54.\¬
Rounding, 51--55, 92--93.\¬
\&{rpen}, 24, 28, 48--50, 62.\¬
\&{rt}, 8, 28, 42.\¬
Running \MF, 29--38.
\newletter s
\&{safetyfactor}, 48, 65, 81.\¬
Scaling, 5, 10, 51, 64--65.\¬
Sections of a program, 61--62.\¬
``{\tt Sharp turn suppressed ...}'', 21, 77.\¬
Shoemaker's problem, 17--19.\¬
\&{sind}, 42, 81.\¬
Slanting, 65, 84.\¬
Sole, 17--19, 23.\¬
Solution of equations, 5--6, 31--33, 40--41.\¬
Spaces, 40.\¬
\&{spen}, 24--25, 28, 48--49, 62.\¬
Spline functions, 20--22, 50.\¬
\&{sqrt}, 42, 46.\¬
Square root symbols, 101.\¬
Stable pen size, 50, 63.\¬
Statements, 4, 62--68.\¬
Straight line, 6.\¬
Subroutines, 55--61, 91--94.\¬
Subscripts, 31.\¬
Subtraction, 44.\¬
Summary of the language, 61--69.\¬
Superellipse, 57--58.\¬
Symmetry, 53.
\newletter t
Term expressions, 43.\¬
\TEX, 34, 38, 65, 68, 73, 78, 95--101.\¬
\&{texinfo}, 68, 98--100.\¬
Text editor, 36--37.\¬
\&{tfxmode}, 34, 68--69, 96.\¬
Titles, 34--35, 45, 64, 77.\¬
\&{titletrace}, 34, 64, 66.\¬
Tokens, 36--37, 70.\¬
\&{top}, 8, 28, 42.\¬
Tracing, 66--67, 70.\¬
Transformation, 51, 64--65, 67.\¬
Triangular pen, 27.\¬
\&{trxx}, 51, 64--65, 67.\¬
\&{trxy}, 51, 64--65, 67.\¬
\&{tryx}, 51, 64--65, 67.\¬
\&{tryy}, 51, 64--65, 67.\¬
Turning points, {\sl see} Extreme points, Inflection points.
\newletter u
``{\tt ! Undefined factor}'', 31, 78.\¬
Union Jack (partial), 6.\¬
Unknown variables, 41.
\newletter v
$v↓0$, 22--23, 28, 48.\¬
\&{var}, 56, 58, 64.\¬
\&{varchar}, 68, 100.\¬
Variable-size delimiters, 100--101.\¬
Variables, 39--40, 45, 56--57, 61.\¬
Velocities, 21--22, 65, 77, 79.\¬
Vertical extrema, 16, 19, 54.\¬
\&{vpen}, 22--23, 28, 48--50, 62, 65.\¬
\&{vpenwd}, 23, 65, 88.
\newletter w
$w$-variables, 7, 32, 39, 56--57.\¬
$wxy$-variables, 39.
\newletter x
$x$-variables, 4, 32, 39, 56--57, 61.\¬
XGP (Xerox Graphics Printer), 33, 68, 86.
\newletter y
$y$-variables, 4, 32, 39, 56--57, 61.
\newletter .
{\tt"}, 34--35, 45, 64, 77.\¬
\hbox{\hash}, 24, 27, 45, 50, 62--63.\¬
{\≡%≡\}, 35.\¬
{\≡≡'≡\}, 39.\¬
{\≡≡`≡\}, 39.\¬
{\tt(}, 45--46, 58.\¬
{\tt)}, 45--46, 58.\¬
{\tt *}, 43.\¬
{\tt +}, 44.\¬
{\tt ,}, 14, 24, 27, 46, 58, 63, 68.\¬
{\tt -}, 44.\¬
{\tt /}, 43.\¬
{\tt :}, 55, 59.\¬
{\tt <}, 60.\¬
{\tt \char'32}, 60.\¬
{\tt =}, 5, 30, 40, 45, 60.\¬
{\tt \char'33}, 60.\¬
{\tt >}, 60.\¬
{\tt[}, 43--44, 56, 94.\¬
{\tt]}, 43--44, 56, 94.\¬
{\≡{≡\}, 14, 63.\¬
{\≡}≡\}, 14, 63.\¬
{\tt|}, 49--50, 63.\¬
{\tt.}, 40, 45--46, 61--62.\¬
{\tt..}, 6, 46, 63.
\par\vfill
\postindexappbegin Z. {Dragon curve for Fig.\ 4--2}
\vfill
{\baselineskip 0pt \lineskip 0pt\:;
gggggdaggda\par
ggggdfbgdfb\par
ggggceadeeada\par
ggggdfebcbcfb\par
gdagcfeagggca\par
dfbgdbcbgggdb\par
ceadeaggggcb\par
dfefefa\par
cbceefea\par
ggdffbcb\par
ggcbca\par
ggggdfadadaggggdadaggggdada\par
gdagcfeeefeagggcefeagggcefea\par
dfbgdfeffbcbgdadfbcbgdadfbcb\par
ceadeeefeagggcefeagggcefea\par
dfefefefffadadefffadadefffadada\par
cbceebceebceefeeefeeebceebceefea\par
ggdfbgdfbgdfffefffffbgdfbgdffbcb\par
ggcbggcbggcbceefeeefagcbggcbca\par
ggggggggggggdfefefefbgggggggdfa\par
gggggggggdagcfeeebceagggggggcfea\par
ggggggggdfbgdfefbgdfbggggdggdbcb\par
ggggggggceadeeefagcbgggggcadea\par
ggggggggdfefefefbgggggggggcbcb\par
ggggggggcbceebcea\par
ggggggggggdfbgdfb\par
ggggggggggcbggcb\par}
\vfill
\specialappbegin {\char5}. {Pseudo-random design}
\vskip -5pt
{\baselineskip 0pt \lineskip 0pt\:;
dadadadadadadadadadadadadadadada\par
cffeefeefeeeeffffffeffefefefeeeb\par % 1200 bits of pi, f=1 and e=0
dfeeefeeeefeffefeeeffeeeefeeeffa\par
cefeeffeeefeeffeeeffeeffeeefefeb\par
deefefffeeeeeeeffefffeeeeefffeea\par
cffefeeefeefefeefeeeeeefeefeeffb\par
dfeeeeefeeefeeefefeeffeefffffeea\par
cffeeefffefeeeeeeeefeeeeefefffeb\par
dfffffefefeeffeeefffeffeeefeeffa\par
cfeeffeffeefeeefeefefeeefefeefeb\par
dfeeeeefeeeeffffeeffeeefffeeeffa\par
cefeeeeeeefeeffefffeffffefffffeb\par
defefefeeeffeeffeffeeffffeeffefa\par
ceefffefeefeeeeffeeeffeffeeffeeb\par
deeeefefeffeeeefefeeffeffefffffa\par
ceefeefefffffeeefefeeeeffefffefb\par
deefffffffeeeefeeffefefeffeffefa\par
ceffeffefefefeeefffeeeefeefeeefb\par
deffffeefeefeeeefeffeffefefefffa\par
ceffeeffeeefeefeffffeeffffffeffb\par
deeeffeffffefeeefeeffeeefeeeefea\par
cfffefeeffefeeffeeeffeffffffeffb\par
defeffefeffeeeefeffffffffffefefa\par
cffeefeffeffeffffefeeeeeeeffefeb\par
dffeffffffeffeffffefffeeefffeeea\par
ceffefefffffffeffefeffefefeeefeb\par
deffeeffffffefeefeffefefffefeefa\par
cffffeefeefeeeeefeeefefffffeeefb\par
deefeffeeeffffffffeeffeefeefeefa\par
ceefefeeeeffeeffeefefeeeffffeffb\par
deefffeefeeefeffeffeeffffefffeea\par
ceefeeeeeeeeeefffffeefefffeeefeb\par
dfeeeefeffeeefffeffffffeeeeefefa\par
cfeeffeeeffeffefeefeefeeeeeffefb\par
dfeeeefffeeefefefefffefeefffeefa\par
cfefeeffefeefeeefeffeeefffffffeb\par
dfefeeeffffffefeefeefeeffeeffffa\par
cefeffffffeeeeeffeffeefefefefffb\par
defeefeeeffffefffeefefeeefffefea\par
cffeffeefeffeeeefffeeeffeeefeffb\par
dffeeffefefeffeeefeeeeefeeeefefa\par
cbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\par}
\vfill
\end